Re: Intercept Save when closing NSDocument

2017-02-10 Thread Trygve Inda
On 2/10/17, 9:19 AM, "Keary Suska"
<cocoa-dev-bounces+cocoadev=xericdesign@lists.apple.com on behalf of
cocoa-...@esoteritech.com> wrote:

>
>> On Feb 10, 2017, at 9:12 AM, Trygve Inda <cocoa...@xericdesign.com>
>>wrote:
>> 
>> When I close an NSDocument, it puts up a sheet offering (Don¹t Save,
>> Cancel, Save).
>> 
>> Is there a way to intercept this? I would like to disable the Save
>>button
>> for a demo version of our app. I could mark the document as having no
>> changes, but then it would just close directly and not allow a cancel
>> operation.
>> 
>> I can easily disable the menu Save/Save As but clicking the Save button
>>in
>> the close-sheet window jumps right into the file writing methods in my
>> NSDocument subclass.
>> 
>> Thanks for any ideas.
>
>I would start by overriding -saveDocument: and -saveDocumentAs: in your
>NSDocument subclass with a breakpoint so I can see what is being done. I
>might also start by subclassing
>-runModalSavePanelForSaveOperation:delegate:didSaveSelector:contextInfo:
>to see if that is the method used in these cases. Then there are also
>autosave issues if you intend to support autosave in your app...

Yup - I have overridden -saveDocument: and -saveDocumentAs:

They are called from the File-Save and File-Save As points, but not from
clicking Save in the “document is about to close” dialog. I am not
supporting Autosave as I am dealing with very large files.

Trygve





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Intercept Save when closing NSDocument

2017-02-10 Thread Trygve Inda
When I close an NSDocument, it puts up a sheet offering (Don¹t Save,
Cancel, Save).

Is there a way to intercept this? I would like to disable the Save button
for a demo version of our app. I could mark the document as having no
changes, but then it would just close directly and not allow a cancel
operation.

I can easily disable the menu Save/Save As but clicking the Save button in
the close-sheet window jumps right into the file writing methods in my
NSDocument subclass.

Thanks for any ideas.

Trygve




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Class is implemented in both

2016-08-15 Thread Trygve Inda
> 
>> On Aug 15, 2016, at 3:41 AM, Stephane Sudre  wrote:
>> 
>> . you could redefine the class name in the .pch of one project.
> 
> +1 — I’ve had to do this before, and it works fine. Just add
> #define MyDisplayManager MyDisplayManager_PP
> or whatever.
> 
> The caveat is that of course IB doesn’t read the PCH, so you’ll have to
> manually change the class name in any nibs it may appear in.
> 
> —Jens

Both projects share a common pch. Is there a way to add a second pch to just
one of them?




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Class is implemented in both

2016-08-14 Thread Trygve Inda
I have a Pref Pane and a Screen Saver module. They both share a common
helper class (MyDisplayManager).

When the pref pane has been loaded and I go into the screen saver (or vis
versa), because the host app is System preferences, I get:

Class MyDisplayManager is implemented in both One of the two will be
used. Which one is undefined.

The class comes from the same source file. What is the best way to handle
this? I could ignore it because the classes are the same (same source file)
so it should not matter which one is used.

Is there a better way without duplicating and renaming the class?

Thoughts?



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Core Data or not

2016-08-06 Thread Trygve Inda
> To do it as one fetch you can set your predicate (or a sub predicate)
> as: [NSPredicate predicateWithFormat:@"%K in %@", primaryKey, keys] where
> primaryKey is the name of your ID property, and keys is an array of ID
> values which are "interesting" (as defined by the rest of your code).
> 

Thanks for this. Any idea how efficient this is?

Currently I keep a dictionary of my objects which is keyed on the
"interestingField" (a UUID). To gather a user-defined set of them I use a
loop with something like:

for (NSString* uuidString in mySetOfUUIDS)
   [collectedArray addObject:[dict objectForKey:uuidString]];

I wonder how fast each would be if I were collecting 500 out of 5000
objects?





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Core Data or not

2016-08-06 Thread Trygve Inda
> On Aug 6, 2016, at 1:46 AM, Trygve Inda <cocoa...@xericdesign.com> wrote:
>> For example, I would need to add items with ID# 204, 765, 983, 124, and 458
>> to the array. This seems like with Core Data it would be 5 different
>> fetches. Or is there some efficient way to fetch these 5 items in one
>> request?
> 
> You could add an entity to your data model that represents the custom
> collection.  It would have an attribute that is a one-to-many relationship to
> InterestingObject.  If you only have one of those manually-constructed tables,
> your data store would only contain one instance of this entity.  That's
> perfectly okay.
> 
> --Andy
> 
> 

I can't do that at run time though. I need the user to be able to build
custom collections (like a custom iTunes playlist) that is a subset of the
full collection but not by any simple predicate criteria.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Core Data or not

2016-08-05 Thread Trygve Inda
> Little different perspective, Core Data tends to work drop dead easy for
> simple stuff. Small data set with simple functionality should work straight
> out of the box easy.
> 
> And there is nothing wrong with creating a manual array of managed objects
> from a Core Data result set.

Currently I have an NSTableView tied to an NSArrayController. I manually
populate the array controller as needed with items from my master array.

With Core Data it seems the NSArrayController would be tied to the Managed
Context and while I could apply a predicate to filter the array controller,
manually populating it would be slow.

For example, I would need to add items with ID# 204, 765, 983, 124, and 458
to the array. This seems like with Core Data it would be 5 different
fetches. Or is there some efficient way to fetch these 5 items in one
request?




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Core Data or not

2016-08-05 Thread Trygve Inda
I am considering moving an app to Core Data. Currently it manages an array
of InterestingObjects. I use NSArrayControllers and TableViews. Everything
works.

I have two cases:

1. I have one array of all InterestingObjects and I set different predicates
on the array controller to show only those matching the predicate in a
table. (Think of this as an iTunes smart folder)

2. I manually insert some of the InterestingObjects into an array controller
to be shown in a table. (Think of this as an iTunes user-defined folder -
just dragging in random songs)

#1 seems easy to migrate to Core Data as the table will be bound to my
managed object context and I can use predicates to show different subsets.

How can I effectively do #2?

Each InterestingObject has an identifier that is a UUID so I could make a
predicate that just lists all the InterestingObjects I am colleting. Will
that be effective with perhaps hundreds of objects?

Without Core Data it is easy to just go through the array and pick out a
hundred, add them to a different array and display them.

Basically I have a core data store of 5,000 InterestingObjects. I have a
list of 200 UUIDs (remember, each InterestingObject has a UUID) and I need
to list these 200 InterestingObjects in a table.

In some cases I need to combine them, so how is the best way with Core Data
to show a table of:

- all the InterestingObjects where name= "Joe"
- plus all the InterestingObjects with these 200 UUIDs

I hope this is clear.

Somehow this seems easier to do without Core Data.

Thanks.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Method name starts with "set"

2016-08-01 Thread Trygve Inda
I have a class where I would like to have a method name like:

-(void)setMaximumOperations:(NSInteger)operations
{
  [[self operationQueue] setMaxConcurrentOperationCount:operations];

   ... Do other stuff ...
}

Is this a bad idea? There is no property called "maximumOperations" in my
class but using a "set" method name in this way may imply there is, although
the compiler likely doesn't care.

How is the best way to name something like this?




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSImage from bitmap - then delete bitmap

2016-07-26 Thread Trygve Inda
>> 
>> I would think that even with a retain it could get weird...
>> 
>> The main thread wants to use the imageRef property so it calls:
>> 
>> myRef = [window.imageRef];
>> [myref retain];
>> 
>> If right between these calls, the worker thread calls setImageRef (on a
>> property with atomic, copy), then the retain call in the main thread might
>> be on something that has already gone away.
>> 
>> I just don't see how I can safely set the property on a worker thread and
>> read it on the main thread without some risk of it being released behind my
>> back.
> 
> As Graham points out, and as we used to discuss often back in the old MRR
> days, atomic getters likely put the value in the autorelease pool, you should
> go see if that’s the case or not.

How can I tell? I can't even do a retainCount without first calling the
getter.





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSImage from bitmap - then delete bitmap

2016-07-26 Thread Trygve Inda
> 
>> On 27 Jul 2016, at 12:05 PM, Trygve Inda <cocoa...@xericdesign.com> wrote:
>> 
>> How is it retained by the main thread without an explicit retain call?
>> 
>> I would be no different than a main thread calling:
>> 
>> someVar [[MyObj alloc] init]
>> [someVar doSomething];
>> 
>> If a worker thread were able to call [someVar release] between these two
>> lines, the doSomething call could fail.
> 
> 
> The atomic setter method probably looks something like this:
> 
> - (void) setImageRep:(NSImageRep*) rep
> {
> @synchronized( self )
> {
> [rep retain];
> [_imageRep autorelease];
> _imageRep = rep;
> }
> }
> 
> i.e. the old value is autoreleased. Which thread’s pool gets that autorelease
> is a matter for consideration though. I have no idea if it’s just left to the
> caller’s pool, or if there are steps taken to ensure it ends up in the main
> pool. Even if it’s the caller’s pool, unless you’re draining it on each loop,
> it may only ever get drained when the thread ends, which is safe. But it could
> accumulate a lot of unreleased memory which is another potential problem.
> 
> Threads are tricky ;)

And BTW I am draining the pool on each loop of the worker thread.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSImage from bitmap - then delete bitmap

2016-07-26 Thread Trygve Inda
> 
>> On 27 Jul 2016, at 10:05, Trygve Inda <cocoa...@xericdesign.com> wrote:
>> 
>>> 
>> 
>> How is it retained by the main thread without an explicit retain call?
> 
> are you not using ARC? If you are then all such references, both variable and
> during method calls are retained automatically. If you’re not, then do what
> ARC does and retain it explicitly and release it explicitly (and start using
> ARC in that case!)

This is non-ARC code. It is a large project and convertig to ARC is a huge
amount of work.

>> 
>> I would be no different than a main thread calling:
>> 
>> someVar [[MyObj alloc] init]
>> [someVar doSomething];
> 
> That isn’t compilable code. Did you mean
> 
> someVar = [ [ MyObj alloc]init ]
> [ someVar doSomething ];

Yes.

> 
> Again if you’re using ARC, none of these issues are issues.
> 
> Why would a worker thread call [ someVar release ] on a variable it didn’t
> retain in the first place? If that’s actually a realistic scenario and you’re
> not using ARC, then call retain on someVar when you assign it in the first
> place and release it only after you’re finished with it, after the call to
> doSomething. Which, by the way, is pretty much what ARC does.

I would think that even with a retain it could get weird...

The main thread wants to use the imageRef property so it calls:

myRef = [window.imageRef];
[myref retain];

If right between these calls, the worker thread calls setImageRef (on a
property with atomic, copy), then the retain call in the main thread might
be on something that has already gone away.

I just don't see how I can safely set the property on a worker thread and
read it on the main thread without some risk of it being released behind my
back.









___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSImage from bitmap - then delete bitmap

2016-07-26 Thread Trygve Inda
> 
>> On 27 Jul 2016, at 09:33, Trygve Inda <cocoa...@xericdesign.com> wrote:
>> 
>> 
>> 
>> If the worker thread calls window.imageRep = myResult; it is possible that
>> the main thread is in the middle of a call like:
>> 
>> [[window.imageRep]
>> drawInRect:fromRect:operation:fraction:respectFlipped:hints:]
>> 
>> So when the setter (called from the worker thread) replaces the old imageRep
>> with a new one, the old one's retain count goes to zero and it will
>> disappear.
>> 
>> I know atomic makes the call safe as far as a vaild value is concerned, but
>> the main thread could call window.imageRep and get a valid value (because it
>> is atomic), but before it is able to use this value, the worker thread calls
>> the setter which causes the imageRep obtained by the main thread to be
>> released.
> 
> No it couldn’t - because when the main thread calls window.imageRep it gets a
> reference which, whether it assigns it to a variable or just uses it in in a
> chained call (like you have above with drawInRect:.) is retained by the main
> thread during the life of that variable or during the call. So it doesn’t
> matter if the worker thread replaces it after the call to window.imageRep, the
> main thread’s reference remains valid and usable and is only released when
> it’s finished with it and only then gets deallocated (if nothing else is
> referencing it)
> 

How is it retained by the main thread without an explicit retain call?

I would be no different than a main thread calling:

someVar [[MyObj alloc] init]
[someVar doSomething];

If a worker thread were able to call [someVar release] between these two
lines, the doSomething call could fail.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSImage from bitmap - then delete bitmap

2016-07-26 Thread Trygve Inda

> e.g.
> 
> worker thread:
> 
> while( self.running )
> {
> // do work
> 
> window.imageRep = myResult;  // window.imageRep is (atomic, copy)
> 
> [performOnMainThread: window.setNeedsDisplay];  // this is obviously
> pseudocode!
> }
> 
> 
> main thread, when it needs to terminate worker thread:
> 
> workerThread.running = NO;
> 
> 
> both workerThread.running and window.imageRep are atomic properties.

I am not sure this is safe.

window.imageRep is (atomic, copy)

If the worker thread calls window.imageRep = myResult; it is possible that
the main thread is in the middle of a call like:

[[window.imageRep] 
drawInRect:fromRect:operation:fraction:respectFlipped:hints:]

So when the setter (called from the worker thread) replaces the old imageRep
with a new one, the old one's retain count goes to zero and it will
disappear.

I know atomic makes the call safe as far as a vaild value is concerned, but
the main thread could call window.imageRep and get a valid value (because it
is atomic), but before it is able to use this value, the worker thread calls
the setter which causes the imageRep obtained by the main thread to be
released.

I think you'd only want to call the setter from the main thread.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSImage from bitmap - then delete bitmap

2016-07-23 Thread Trygve Inda
> On Jul 22, 2016, at 19:29 , Graham Cox  wrote:
>> 
>> If the worker thread is waiting for -performOnMainThread to complete, it
>> *cannot* possibly get a call from the main thread to terminate
> 
> I nodded agreement when I first read this, then “but wait!” …
> 
> Your logic seems flawed on two counts:
> 
> 1. The selector performed by the worker thread may still be queued, so the
> main thread is doing something else which may result in an attempt to
> terminate the worker thread.

This exactly. We have seen it happen 5 times out of potentially millions of
runs. Only recently did we track down what is happening through a lucky
report submitted by a customer.

T.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSImage from bitmap - then delete bitmap

2016-07-22 Thread Trygve Inda
 
>> Currently it blocks at this point, but I need to avoid that.
> 
> It’s not really clear why this needs to be avoided. The time to draw the
> pixels should be a few milliseconds, a small fraction of the time your thread
> needs to run, even at its fastest.

Because the main thread sometimes needs to ask the worker threads to
terminate. If it does this after performOnMainThread has been called by a
worker thread, but before the main thread has processed it, then the main
thread will block waiting for the worker thread to exit, but the worker
thread has already blocked when it called performOnMainThread.

Very rare, but it can happen.

>> Since it can't
>> block,
>> the pixels need to be copied to the main thread because as soon as
>> they get handed to the main thread, the worker thread will erase the
>> original pixel buffer to start drawing a new image into it.
> 
> Copying the image is likely to be just as slow/fast as drawing it, so the copy
> isn’t going to help speed up your thread. Both operations have to iterate over
> the pixels; drawing *IS* copying.

Speed isn't really the issue. The issue is changing the code so that the
worker thread never has to block. To do so the pixels need to handed off to
the main thread in such a way that the worker thread can then destroy the
original pixels (by writing over them with new data)

>> The copy needs to exist long enough to be drawn into a window by the main
>> thread and can then be released.
> 
> Understood, but you may as well keep it around until the next version of the
> image is passed across - the previous one will be released at the same time
> when setting the property.

Yup - that's possible too.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSImage from bitmap - then delete bitmap

2016-07-22 Thread Trygve Inda
> 
>> On 22 Jul 2016, at 4:08 PM, Trygve Inda <cocoa...@xericdesign.com> wrote:
>> 
>> I don't think the second part will work because of my workflow:
>> 
>> At Launch: Create pixel buffer that is 1000 x 1000 pixels
>> 
>> Looping thread
>> 1. Fill pixel buffer with pixels based on some algorithm
>> 2. create an NSImage with these pixels
>> 3. pass it to the main thread to be drawn in a window
>> Restart the loop with a  slightly modified algorithm
>> 
>> If calling this:
>> [myImage addRepresentation:theBitmapIMadeFirst];
>> 
>> Only causes the NSImage to retain it, then when I change the pixels in the
>> bitmap, they get changed in the NSImage.
>> 
>> I need the NSImage to keep the pixels as they existed when I created it.
> 
> 
> Do you?
> 
> Once the image is drawn into the window, it’s effectively copied to the
> window’s backing store, so there’s already a second copy of the pixels.
> 
> The only situation that might cause a problem is if the window can possibly be
> called upon to redraw at a time when the bitmap is being updated but hasn’t
> yet completed. If the code that fills the buffer is synchronous, that can
> never happen. If the code is asynchronous (e.g. on a second thread), then you
> *might* want a copy of the bitmap, but only if drawing it halfway through
> updating would actually be bad - that depends entirely on what is being drawn.
> If it’s a minor/subtle change, it may not be noticeable.
> 
> With half an eye on performance, if you *do* strictly need a copy of the
> bitmap, note that NSBitmapImageRep conforms to NSCopying. You don’t have to
> turn it into a TIFF and back again.
> 
> Also, you don’t even need an NSImage - the NSImageRep can be drawn directly.

How can I draw the NSImageRep  directly into a window?

Also, the main pixel buffer is updated slowly (it takes a long time to
draw). So once the worker thread is done, it needs to pass off those pixels
to the main thread to be drawn.

Currently it blocks at this point, but I need to avoid that. Since it can't
block, the pixels need to be copied to the main thread because as soon as
they get handed to the main thread, the worker thread will erase the
original pixel buffer to start drawing a new image into it.

The copy needs to exist long enough to be drawn into a window by the main
thread and can then be released.





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSImage from bitmap - then delete bitmap

2016-07-22 Thread Trygve Inda
 
>> This is how it works now, but we are running into a rare deadlock situation
>> where the main thread asks the worker thread to end (and waits until it does
>> so) while the worker thread is waiting for the image to be displayed.
> 
> If the window has a imageRep property that is (atomic, copy) you shouldn’t run
> into a deadlock where the window tries to terminate the thread and it happens
> to be calling that method at the time. If you go with Roland’s suggestion, it
> doesn’t need to be copy, it can simply be strong. But make it atomic, as the
> property will need to be accessed from both the main and the worker threads
> and the rep must be in a viable state at both times.

Ultimately there needs to be more than one copy of the pixels because as
soon as the worker thread is done building the image, it hands it off to the
main thread to be displayed.

Currently it blocks until the main thread displays it, so only one set of
pixels is needed. But to prevent deadlock, the worker thread really needs to
just hand of a copy of the pixels, then erase the original pixels and start
a new image.

[bitmapImageRep copy] might be the best solution here.

T.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSImage from bitmap - then delete bitmap

2016-07-22 Thread Trygve Inda
> 
>> On 22 Jul 2016, at 4:40 PM, Trygve Inda <cocoa...@xericdesign.com> wrote:
>> 
>> 
>>> With half an eye on performance, if you *do* strictly need a copy of the
>>> bitmap, note that NSBitmapImageRep conforms to NSCopying. You don’t have to
>>> turn it into a TIFF and back again.
>>> 
>>> Also, you don’t even need an NSImage - the NSImageRep can be drawn directly.
>> 
>> 
>> A little deeper discussion of how my app works.
> 
> I have an idea I know what this app is, so I understand what you need to do. I
> won’t name names if you don’t :) I believe I am a registered user.
> 
> 
>> 
>> I have a background worker thread whose purpose is to generate a continuous
>> series of NSImages - from one per second to one every 5 minutes or so). I
>> may have several of these worker threads working on different images.
>> 
>> The thread starts by making a pixel buffer using:
>> 
>> [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL ..
>> 
>> Then the thread goes into a loop where on each pass it draws the correct
>> image into this pixel buffer.
>> 
>> After the image is drawn it need to be handed off to the main thread to be
>> drawn into a window.
>> 
>> As soon as it is handed off, the thread starts drawing a new image,
>> destroying the pixels used to create the image that was just handed off.
>> 
>> It is likely that the image will not be received by the main thread and
>> drawn into the window before the pixels in the NSBitmapImageRep  are
>> destroyed (because it the thread is now drawing a new image).
>> 
>> So how is the best way to take my NSBitmapImageRep, and hand it off to the
>> main thread in such a way that I can destroy the pixels immediately while
>> the main thread keeps them?
>> 
>> Would it be best to just call [myImagerep copy], and hand that to the main
>> thread, and let the main thread release it once it has draw it into the
>> window?
>> 
> 
> 
> I have an idea I know what this app is, so I understand what you need to do. I
> won’t name names if you don’t :) I believe I am a registered user.> I think
> you have two choices.

Without naming names, I am sure your hunch is accurate.
 
> You can pass the rep to the window using
> performSelectorOnMainThread:withObject:waitUntilDone: passing YES for wait
> until done, in which case your worker thread will be stalled just long enough
> to draw the image and copy to the backing store. After that you’re free to
> continue modifying the rep.

This is how it works now, but we are running into a rare deadlock situation
where the main thread asks the worker thread to end (and waits until it does
so) while the worker thread is waiting for the image to be displayed.

I have never seen it happen here, but I have tracked it down from hang
reports and need to figure out the best way to hand the pixels off to the
main thread in such a way that there are no dependencies on the original
pixel buffer because as soon as the pixels are handed to the main thread,
the worker thread will be changing the pixels in the original buffer.





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSImage from bitmap - then delete bitmap

2016-07-22 Thread Trygve Inda

> With half an eye on performance, if you *do* strictly need a copy of the
> bitmap, note that NSBitmapImageRep conforms to NSCopying. You don’t have to
> turn it into a TIFF and back again.
> 
> Also, you don’t even need an NSImage - the NSImageRep can be drawn directly.


A little deeper discussion of how my app works.

I have a background worker thread whose purpose is to generate a continuous
series of NSImages - from one per second to one every 5 minutes or so). I
may have several of these worker threads working on different images.

The thread starts by making a pixel buffer using:

[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL ..

Then the thread goes into a loop where on each pass it draws the correct
image into this pixel buffer.

After the image is drawn it need to be handed off to the main thread to be
drawn into a window.

As soon as it is handed off, the thread starts drawing a new image,
destroying the pixels used to create the image that was just handed off.

It is likely that the image will not be received by the main thread and
drawn into the window before the pixels in the NSBitmapImageRep  are
destroyed (because it the thread is now drawing a new image).

So how is the best way to take my NSBitmapImageRep, and hand it off to the
main thread in such a way that I can destroy the pixels immediately while
the main thread keeps them?

Would it be best to just call [myImagerep copy], and hand that to the main
thread, and let the main thread release it once it has draw it into the
window?





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSImage from bitmap - then delete bitmap

2016-07-22 Thread Trygve Inda
> 
>> On 22 Jul 2016, at 3:37 PM, Trygve Inda <cocoa...@xericdesign.com> wrote:
>> 
>> I create an NSBitmapImageRep:
>> 
>> [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
>> pixelsWide:pixelSize.width
>> pixelsHigh:pixelSize.height
>> bitsPerSample:8
>> samplesPerPixel:4
>> hasAlpha:YES
>> isPlanar:NO
>> colorSpaceName:NSDeviceRGBColorSpace
>> bitmapFormat:NSAlphaFirstBitmapFormat
>> bytesPerRow:pixelSize.width * 4
>> bitsPerPixel:32]
>> 
>> I then get the address by sending a "bitmapData" message to the object
>> 
>> After filling it with image data, I call:
>> 
>> NSImage* image =
>> [[NSImage alloc] initWithData:[myImageRep TIFFRepresentation]];
>> 
>> So now I have an NSImage. What happens if I delete/release myImageRep (my
>> NSBitmapImageRep)?
> 
> Nothing. The rep isn’t doing anything after this point; you can release it
> safely.
> 
>> Has the call to NSImage copied my pixels so that they are self-contained
>> within the NSImage?
> 
> Yes.
> 
> But that’s not a great way to do this. You’ve made an image, you’ve encoded it
> as TIFF data, then you’ve made a new image, which has decoded the TIFF data to
> make a new image rep/bitmap.
> 
> You could just add the representation directly to a new NSImage (warning:
> typed into Mail, check method names):
> 
> NSImage* myImage = [[NSImage alloc] initWithSize:NSMakeSize(width,height)];
> 
> [myImage addRepresentation:theBitmapIMadeFirst];
> 
> [theBitmapIMadeFirst release]; // because NSImage retained it


I don't think the second part will work because of my workflow:

At Launch: Create pixel buffer that is 1000 x 1000 pixels

Looping thread
1. Fill pixel buffer with pixels based on some algorithm
2. create an NSImage with these pixels
3. pass it to the main thread to be drawn in a window
Restart the loop with a  slightly modified algorithm

If calling this:
[myImage addRepresentation:theBitmapIMadeFirst];

Only causes the NSImage to retain it, then when I change the pixels in the
bitmap, they get changed in the NSImage.

I need the NSImage to keep the pixels as they existed when I created it.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSImage from bitmap - then delete bitmap

2016-07-21 Thread Trygve Inda
I create an NSBitmapImageRep:

[[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:pixelSize.width
pixelsHigh:pixelSize.height
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bitmapFormat:NSAlphaFirstBitmapFormat
bytesPerRow:pixelSize.width * 4
bitsPerPixel:32]

I then get the address by sending a "bitmapData" message to the object

After filling it with image data, I call:

NSImage* image =
[[NSImage alloc] initWithData:[myImageRep TIFFRepresentation]];

So now I have an NSImage. What happens if I delete/release myImageRep (my
NSBitmapImageRep)?

Has the call to NSImage copied my pixels so that they are self-contained
within the NSImage?

If not, how can I do so? I am using a single NSBitmapImageRep and trying to
reuse it while making many different NSImage objects, each with their own
data.

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Custom window disappears dragging to second display

2016-05-02 Thread Trygve Inda
I have a custom window that basically eliminates the large title area.

When you drag a normal window to a second screen, as the drag is in
progress, the window appears semi-transparent on the second screen until
enough of the window covers the second screen, whereupon it becomes opaque
on the second screen and semi-transparent on the original one.

With my custom window, as the drag is in progress, the window portion that
is supposed to be semi-transparent is 100% transparent - not visible at all.

What would cause this?

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Core Data user-defined fields

2016-05-02 Thread Trygve Inda
I have a core data document-based app at the document level is a Core Data
type called Library, with a one to many relationship to type Element.

Element has a few properties but I want to allow the user to add others (of
type string only at this point).

So I have Element:

String name
String propA
String propB
String propC

I think I need to add a one-to-many

Set userProperties

And a UserProperty type would have two properties:

String propName
String propValue

When all this is displayed in a table bound with Core Data. I want a column
for propD (so a UserProperty with propName = "propD").

How do I show the values since I have to go:

element.userProperties, then get to propName = "propD" and then grab the
propValue?

Is it important to make sure all elements have this? I'd like users to be
able to enter values in the table.

Properties for propA, propB, propC are easy but I need to user to be able to
create a column for propD and add values for some (or all) elements.

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Xcode Source Compiling Order Issue

2016-04-25 Thread Trygve Inda
My product is a System Preferences Pane. Its principal class is MyPrefPane
and is defined correctly in the Info.plist file under NSPrincipalClass.

The bug I am seeing happens when trying to install a new version over the
top of an older one if (and only if) System Preferences is closed or System
Preferences is open but the older pane has not been clicked on (and is thus
not loaded).

I get an error that my pref pane can't run on an Intel Mac and console
reports:

System Preferences[10232]: -[MyMinorClass initWithBundle:]: unrecognized
selector sent to instance 0x7fc60be96170

System Preferences[10232]: [NSPrefPaneBundle instantiatePrefPaneObject]:
error occurred during instantiation.

It seems like System Preferences is trying to init my pref pane by loading a
minor internal class instead of my MyPrefPane class.

In Xcode Build Phases under compile sources, I noticed that the first two
items are:

MyMinorClass.m
MyPrefPane.m

If I reverse these, and compile MyPrefPane.m first, the bug is eliminated.
Putting any other class before MyPrefPane.m results in System Preferences
making the same attempt to call the first-compiled class with
initWithBundle:

Why does the compile order matter?

I found a similar issue here:

http://stackoverflow.com/questions/31373144/xcode-source-compiling-order-iss
ue

He solved it by rebuilding the project. I have just spent 8 hours rebuilding
this complex project and still get the same results as before (this Xcode
project has existed since Xcode 3)

I am unable to reproduce this on a simple Xcode PrefPane template.

Any ideas?

I am not sure if this is an Xcode issue or something in the OS. For now of
course all I can do is make sure the principal class is compiled first.

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Codesign broken in 10.11.4

2016-04-07 Thread Trygve Inda
> This may be relevant, though it does talk about issues with pref panes as
> well.
> 
> http://mjtsai.com/blog/2016/03/31/gatekeeper-bug-in-mac-os-x-10-11-4/

Yup. That sums it up.

The short story: tested with a default Xcode command line tool that says
"Hello World".
 
1) Build a command line tool on 10.11.3 and sign it with my Developer ID.
Everything is fine.

2) Test it on 10.11.4 and spctl gives me an "obsolete resource envelope"
error.

This bug is preventing the release of a major new version of our product.

:(

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Codesign broken in 10.11.4

2016-04-07 Thread Trygve Inda
My app is built on 10.11.3. It is a prefPane with one command line tool and
three app bundles (four helper tools) in it's bundle. I am getting
GateKeeper warnings on 10.11.4 systems, but not on anything else.

It is manually codesigned with my Developer ID... first the helper tool
frameworks, then the helper tools themselves and then the prefPane. So
everything is signed from the inside-out.

In terminal (on two different machines running 10.11.3) I get:

spctl -a -t exec -vv My.prefPane

   /Volumes/Path/To//My.prefPane: accepted
   source=Developer ID
   origin=Developer ID Application: My Company, Inc.

codesign --verbose=4 --deep --strict My.prefPane

   /Volumes/Path/To//My.prefPane: valid on disk
   /Volumes/Path/To//My.prefPane: satisfies its Designated Requirement


In terminal (on two different machines running 10.11.4) I get:

spctl -a -t exec -vv My.prefPane

   /Volumes/Path/To//My.prefPane: rejected
   source=obsolete resource envelope
   origin=Developer ID Application: My Company, Inc.

codesign --verbose=4 --deep --strict My.prefPane

   /Volumes/Path/To//My.prefPane: valid on disk
   /Volumes/Path/To//My.prefPane: satisfies its Designated Requirement


The codesign command is taken directly from what Xcode uses:

codesign --force --sign "Developer ID Application: My Company, Inc."
--requirements "=designated => anchor apple generic and identifier
\"com.mycompany.myproduct.helper\" and ((cert
leaf[field.1.2.840.113635.100.6.1.9] exists) or (certificate
1[field.1.2.840.113635.100.6.2.6] exists and certificate
leaf[field.1.2.840.113635.100.6.1.13] exists and certificate
leaf[subject.OU] = \"MYAPPLE123\"))" --timestamp=none
"$BASEPATH/My.prefPane/Contents/Resources/MyHelper.app"


When I run the above spctl terminal command on the helpers within the bundle
on 10.11.4, the three helper app bundles are accepted but the command line
tool is rejected with "obsolete resource envelope".

If I copy that command line tool to a 10.11.3 system and run spctl, it is
accepted.

I have spent more than a day on this and am at a loss as to what is
happening.

Any ideas?




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSThread to NSOperation and blockUntil

2016-03-21 Thread Trygve Inda
I have a thread that is invoked with:

[NSThread detachNewThreadSelector:@selector(threadMethod:) toTarget:self
withObject:self];

It uses NSConditionLock and works well.

This thread performs a complex process but does it slowly so as to not use
much processor time. I specify how long I want it to take (1 to 30 minutes)
and use:

//  block this task until time has elapsed or an exit signal is received.
if ([[self lock] lockWhenCondition:kConditionThreadMustExit beforeDate:[self
blockUntil]])  
 [[self lock] unlock];

blockUntil simply checks to see how much work has been done vs how much time
has passed and if 50% of the work has been done, blocks until 50% of the
time has passed. It works well since the work is very linear.

I would like to move this to NSOperation and NSOperationQueue but I see no
way to replicate this behavior. My current thread is limited to a single
processor core and with NSOperation I could split it to multiple cores, but
in so doing I seem to lose this "delay for a while" bit.

Any ideas?

Thanks.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSTableView edit line, prevent dialog close with return key

2016-03-19 Thread Trygve Inda
> Ahh, the case of ambiguous ui
> 
> Perhaps Disable OK while editing a cell; enable when edit ends, so
> Return Return accepts then closes?
> 
> Gary

So how do I tell when editing begins since the control delegate is not
called when editing actually begins, but rather when the first key is
pressed once it is already in edit mode??

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSTableView edit line, prevent dialog close with return key

2016-03-19 Thread Trygve Inda
I have an NSTableView in a sheet. The sheet has an OK button which closes
the sheet (and is the default blue button).

If I am editing a line of text in the NSTableView and press return, I want
the editing to stop and be accepted, but I don't want the sheet to close due
to the OK button accepting the return key as well.

How can I do this?



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Can't generate receipt OS X after 173 exit

2016-03-09 Thread Trygve Inda
I am no longer able to generate a receipt after exiting with code 173.

When I launch, I get a box saying that the app was purchased on another
computer and that I need to validate it. I enter my Apple ID and password,
but I get "An unexpected error occurred while signing in"

The Apple ID could not be found or the password is incorrect.

Any ideas?

I tried quiting the store processes in Activity monitor. No joy.

Very frustrating.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Apple Bug no response

2016-03-09 Thread Trygve Inda
I have an open bug report

rdar://24316348

Apple asked for an example to reproduce which I sent on January 27, but I
have heard nothing since. This is a fairly simple bug (NSTextFields can't
fully justify on 10.11).

How long should I expect to wait for a response?

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: PSA: Does your app use Sparkle? Update it, or use an HTTPS server

2016-02-09 Thread Trygve Inda
> If your hosting provider still charges an arm and a leg for SSL, switch.

I need SSL for multiple subdomains. My host (Pair Networks) charges $449/yr
for such a certificate. That seems really expensive. What are others paying
for this? I have been very happy with Pair as we run a complex server setup
with multiple cron jobs, custom C programs etc.

I also see no way to add an SSL certificate to a CNAME'd site at Amazon S3:

download.xericdesign.com CNAME
s3.amazonaws.com/download.xericdesign.com/

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

mmap quiet failure - all reads are 0x00

2016-02-05 Thread Trygve Inda
I have image data that is stored in a 150mb file which I use mmap to read.

The image data is pulled into a NSBitmapImageRep pixel by pixel and
eventually shows on the screen. Only a subset of the pixel in the mmap file
are pulled into a single NSBitmapImageRep.

A few customers (and I have seen it happen here a couple times too) are
reporting that sometimes the image just turns solid black.

It seems like no matter what is in the mmap file, when I read from it I get
0x00 for every byte and no error or exception is generated. I can't
reproduce it as it is very random. Quitting and relaunching solves it.

Any ideas?

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

[NSThread callStackSymbols] weirdness

2016-02-03 Thread Trygve Inda
I am trying to track down a difficult bug on a customer's machine.

I have inserted [NSThread callStackSymbols] at a critical place in the app
where I want to see how it got there.

When running a debug version, either in the debugger or not, I see:

2/3/16 10:53:51.070 PM MyApp Core[22398]: (
0   MyApp Core -[MyClass dealloc] + 115
1   MyApp Core -[MyClass doSomething:] + 234
2   MyApp Core -[MyClass doStuff:] + 292
3   CoreFoundation __CFNOTIFICATIONCENTER_IS_CALLING_OUT + 12
4   CoreFoundation ___CFXRegistrationPost_block_invoke + 63


When running a release version, even with stripping turned off, I see:

2/3/16 10:57:33.978 PM MyApp Core[23142]: (
0   MyApp CoreMyApp Core + 81817
1   CoreFoundation__CFNOTIFICATIONCENTER_IS_CALLING_OUT + 12
2   CoreFoundation___CFXRegistrationPost_block_invoke + 63


My guess is that it is still being stripped somewhere, but why do I get to
see 3 method calls in my own app in the first example, but only the last
call in the second example?

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: App Transport Security exceptions App Store signed app

2016-01-27 Thread Trygve Inda

> Also, have you looked into setting up HTTPS on those servers instead of
> working around its absence? Part of the reason Apple added ATS was to nudge
> app developers to make their network connections more secure, which will
> benefit users.

It is basically a cost issue. It is expensive to set up SSL certificates on
8 different servers... It would cost us about $700/yr and add little benefit
as it has been working fine with http (no s) for more than 10 years.

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: App Transport Security exceptions App Store signed app

2016-01-27 Thread Trygve Inda
> On 26 Jan 2016, at 9:55 pm, Trygve Inda <cocoa...@xericdesign.com> wrote:
> 
>> connection failed: (null) The resource could not be loaded because the App
>> Transport Security policy requires the use of a secure connection.
>> http://www.earthdeskcloudhost02.com/mosaic/free/clouds-2048.jpg
> 
> I'm no App Transport Security expert, but taking what you described at face
> value, that seems to make sense. You tried to load a resource from
> www.earthdeskcloudhost02.com, which is a subdomain of
> earthdeskcloudhost02.com, yet the Info.plist entries you described seemed to
> lack a NSIncludesSubdomains key for the latter domain.
> 
> I imagine that if you either drop the 'www.' or add the NSIncludesSubdomains
> it might work...?

Yeah - I guess I don't really think of the www as being a subdomain, but
indeed it is.

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: App Transport Security exceptions App Store signed app

2016-01-27 Thread Trygve Inda
> 
>> On Jan 27, 2016, at 7:32 AM, Trygve Inda <cocoa...@xericdesign.com> wrote:
>> 
>> It is basically a cost issue. It is expensive to set up SSL certificates on
>> 8 different servers... It would cost us about $700/yr
> 
> Sounds like you’re being overcharged. SSL on hosted domains used to be pricey
> (partly due to the CPU overhead of the encryption) but hosts like Dreamhost
> are now offering it as a free add-on. And Let’s Encrypt makes getting and
> maintaining a cert free and fairly easy.

This is from Pair Networks for an SSL certificate with subdomains.

https://www.pair.com/services/pairssl/

> This is kind of like living in a small town that’s now grown into a big city,
> and still refusing to lock your doors at night. :)
> The site may have been fine so far, but the world around it is changing. Both
> attacks against and surveillance of cleartext connections are increasing, and
> there’s a growing consensus that unencrypted HTTP should be deprecated.
> Apple’s ATS is a sign of that.
> https://blog.mozilla.org/security/2015/04/30/deprecating-non-secure-http/
> https://www.chromium.org/Home/chromium-security/marking-http-as-non-secure
> I think it’s pretty likely that, within a year or so, users of your website or
> app* are going to be seeing scary security warnings in their browser or mobile
> device unless you move to HTTPS.

You could be right. I fail to see why downloading a simple image needs to be
done securely. It is not transmitting anything financial or sensitive.

T.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

App Transport Security exceptions App Store signed app

2016-01-26 Thread Trygve Inda
I am still getting an error despite my Info.plist beign configured correctly
(as far as I can tell).

Calls to http on my domain (xericdesign.com) work. Calls via http to my
other domain (earthdeskcloudhost02.com) do not work.

connection failed: (null) The resource could not be loaded because the App
Transport Security policy requires the use of a secure connection.
http://www.earthdeskcloudhost02.com/mosaic/free/clouds-2048.jpg

My Info.plist has:

NSAppTransportSecurity
- NSExceptionDomains

-- earthdeskcloudhost02.com
--- NSTemporaryExceptionAllowsInsecureHTTPLoads (YES)

-- xericdesign.com
--- NSTemporaryExceptionAllowsInsecureHTTPLoads (YES)
--- NSIncludesSubdomains (YES)

I have also tried the key: NSExceptionAllowsInsecureHTTPLoads

Since some docs say this key should be used.


Any ideas?

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSTextFields will not fully justify in 10.11

2016-01-24 Thread Trygve Inda
> If it's autolayout, double-check it, especially the priorities; it might be
> hugging more than you expect. What does the UI layout debugger show? I've
> found some layout surprises that way.
> 

It is not using Auto-Layout. I tried creating one with Auto-Layout and it
doesn't work either.

I created rdar://24316348

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSTextFields will not fully justify in 10.11

2016-01-24 Thread Trygve Inda
> On Jan 24, 2016, at 07:24 , Trygve Inda <cocoa...@xericdesign.com> wrote:
>> 
>> It is not using Auto-Layout. I tried creating one with Auto-Layout and it
>> doesn't work either.
> 
> For interest’s sake:
> 
> a. If you specify the text field as being left justified instead of fully
> justified, does it wrap at the same or different places in the text? Do you
> get the same problem with a different font, or a larger point size?

Justified wraps exactly the same as Left - regardless of font or size.

> (I’m wondering if it’s a problem with a custom font.)
> 
> b. Are you displaying plain text or attributed text? If attributed, what
> happens to plain text?

Plain text in an NSTextField with static text built in IB/Xcode 7.2.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSTextFields will not fully justify in 10.11

2016-01-23 Thread Trygve Inda
When running in 10.11, my fully justified text fields are no longer so...
They are left justified only.

Is there a fix for this?

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSTextFields will not fully justify in 10.11

2016-01-23 Thread Trygve Inda
> 
>> On Jan 23, 2016, at 7:44 PM, Trygve Inda <cocoa...@xericdesign.com> wrote:
>> 
>> When running in 10.11, my fully justified text fields are no longer so...
>> They are left justified only.
>> 
>> Is there a fix for this?
> 
> Use an NSTextView instead? It’s generally better to use that class when the
> user might enter more than a line or two of text, since it has more features
> (scrollbars, preserving selection when it loses focus, etc.)
> 
> —Jens

These are static text fields (for copyright text which is several lines).

Trygve




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Debug Pref Pane with System Integrity Protection

2015-09-29 Thread Trygve Inda
One of my projects is a System Preference Pane. With 10.11, Xcode's debugger
can't debug it as I get a "can't attach to System Preferences because of
System Integrity Protection".

How can I debug my prefpane under 10.11, as I have done in every OS back to
10.3?



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Thread-safe atomic property for array

2015-08-14 Thread Trygve Inda
My main thread periodically downloads some data from a website. This is
extracted into an NSArray (non-mutable) and placed in a property:

@property (atomic, retain) NSArray* myArray;

[self setMyArray:webArray];

Ok so far... The atomic ensures that the property can be set correctly
even if other threads are reading from it.

However...

I have several threads that need read-access to this array:

NSString* someString = [[hostObject myArray] objectAtIndex:2];

How can I do this safely?

The problem here is that if myArray is being replaced in the main thread
after [hostObject myArray] is called but before objectAtIndex:2 is called,
than myArray will disappear out from under the caller.

So in my thread I could do...

NSArray* arrayCopy = [[hostObject myArray] copy];

Even this could fail if the array is replaced on the main thread before the
copy method gets called.

So, how can I ensure that my threads can grab a copy of the array to work
with while allowing the main thread to update it?

It is ok if the threads copy and work with the array and the array gets
updated.. Having an old version in a thread is fine as they will get a fresh
copy the next time it runs.

I was thinking of storing this in Core Data to allow for all this using a
NSMainQueueConcurrencyType and NSPrivateQueueConcurrencyType, but it would
be simpler if I could avoid all that.

Thanks,

Trygve




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Thread-safe atomic property for array

2015-08-14 Thread Trygve Inda
 On Aug 14, 2015, at 6:59 PM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 My main thread periodically downloads some data from a website. This is
 extracted into an NSArray (non-mutable) and placed in a property:
 
 @property (atomic, retain) NSArray* myArray;
 
 NSString* someString = [[hostObject myArray] objectAtIndex:2];
 
 How can I do this safely?
 
 The problem here is that if myArray is being replaced in the main thread
 after [hostObject myArray] is called but before objectAtIndex:2 is called,
 than myArray will disappear out from under the caller.
 
 One of the things that an atomic property's getter does, for an object pointer
 type, is retain the object within the synchronization and autorelease it
 before returning it.  So, this is safe against that particular problem.  The
 returned array will remain valid within the caller's scope.
 

That's good to hear. I couldn't find that documented anywhere. This seems
like the best solution - and the only place I have ever needed to use an
atomic property.

I can't think of a better way to do this sort of thing other than the Core
Data technique I mentioned in the original post.

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Mavericks vs Yosemite line spacing

2015-08-12 Thread Trygve Inda
I have an NSTextField that is static and has multiple lines. Because of the
different font used in Yosemite, the line spacing is thicker and when
running on Yosemite, it requires more vertical space.

Is there a way to align the text to the bottom of the content box, rather
than the top? Horizontal justification is easy, but I don't see a way to
force it to be bottom-aligned.

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSManagedObject, NSString property retain vs copy

2015-07-30 Thread Trygve Inda
It seems Apple is using retain rather than copy for NSString properties in
an NSManagedObject subclass.

I was always under the impression that copy should be used for NSString, so
why the retain??

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSPrivateQueueConcurrencyType working outside of performBlock

2015-07-29 Thread Trygve Inda
 
 “Setter methods on queue-based managed object contexts are thread-safe. You
 can invoke these methods directly on any thread”
 
 https://developer.apple.com/library/mac/documentation/Cocoa/Reference/CoreData
 Framework/Classes/NSManagedObjectContext_Class/index.html
 


In Apple's example, they use two different contexts, each with their own
NSPersistentStoreCoordinator. But the NSPersistentStoreCoordinators each
point to the same store file URL.

Where is it documented that this works?

If the NSPersistentStoreCoordinator instances are separate, how does it
actually work when they are both writing to the same store (potentially at
the same time)?

All Apple's notes say is:

To ensure that the application can remain responsive during this operation,
the view controller employs a second coordinator to manage interaction with
the persistent store. It configures the coordinator to use the same managed
object model and persistent store as the main coordinator vended by the
stack controller. 


Trygve




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSPrivateQueueConcurrencyType working outside of performBlock

2015-07-28 Thread Trygve Inda
 
 On Jul 28, 2015, at 10:14 AM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 
 On 28 Jul 2015, at 9:12 pm, Trygve Inda cocoa...@xericdesign.com wrote:
 
 I gather that when using NSPrivateQueueConcurrencyType, all operations (a
 fetch for example) have to be done within a performBlock call.
 
 
 ...
 
 Then later, this context is used outside a performBlock:
 
 
 NSArray *matchingQuakes = [taskContext
 executeFetchRequest:matchingQuakeRequest error:anyError];
 
 
 Why does this work?
 
 You are supposed to call performBlock so that all accesses to the MOC are
 serialized on the queue and so you get thread safety that way. However it's
 quite possible to call the methods directly on the MOC in any thread context
 and they will work, all the performBlock() actually does is queue the same
 block of code onto the dispatch queue and when it's its turn, it executes by
 calling [ moc executeFetch.. blah blah].
 
 If you do that of course you have no thread safety any more and are likely
 to
 blow up. In this case there's only one thread (I believe) and so the
 accesses
 are serialized anyway and it works. It's a bad piece of code.
 
 I filed an enhancement report requesting that the coredata stack assert if
 you
 called a private queue MOC method from the wrong queue, I don't recall
 seeing
 anything come of it, however I do remember there is quite a lot of logging
 you
 can turn up on CoreData and it's possible one such log will tell you you're
 doing this. 
 
 If I do use performBlock and have to do several things:
 
 This code is sitting inside a completion block for a URL downloader
 {
[self doSomething];
[myContext performBlock (do more stuff)];
[self doSomethingElse];
 }
 
 
 Since the perform block will run in a different thread, how can I make sure
 the do more stuff is finished before calling doSomethingElse?
 
 Or in this case would using NSConfinementConcurrencyType be better since it
 is all within a completion block and presumably on it's own thread anyway.
 
 
 Use performBlockAndWait instead of performBlock.
 
 Or do something like (typed into Mail so not checked for syntax)
 
 [myContext performBlock:^{
//do whatever operation with myContext
 
// assuming you want doSomethingElse done on main queue
dispatch_async(dispatch_get_main_queue(), ^{
[self doSomethingElse];
   });
 
 }];
 
 I believe NSConfementConcurrencyType is deprecated so you should not use it
 for new code.
 
 I highly recommend you read through the documentation.
 
 https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Referen
 ce/CoreDataFramework/Classes/NSManagedObjectContext_Class/index.html
 
 HTH,
 Dave Reed
 

performBlockAndWait might work. In my completion handler I have basically:

Context = [self createPrivateContect];

For (I = 1; I  something ; i++)
{
...do stuff with completetion data from URL...

...do stuff with the context...

}

So I need to make sure the context stuff finishes before the for loop goes
onto the next pass through the loop.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSPrivateQueueConcurrencyType working outside of performBlock

2015-07-28 Thread Trygve Inda
I gather that when using NSPrivateQueueConcurrencyType, all operations (a
fetch for example) have to be done within a performBlock call.

Apple has sample code here:

https://developer.apple.com/library/mac/samplecode/Earthquakes/History/Histo
ry.html#//apple_ref/doc/uid/TP40014547-RevisionHistory-DontLinkElementID_1

That gets a private queue with:

NSManagedObjectContext *privateQueueContext(NSError *__autoreleasing *error)
{

NSPersistentStoreCoordinator *localCoordinator =
[[NSPersistentStoreCoordinator alloc]
initWithManagedObjectModel:[AAPLCoreDataStackManager
sharedManager].managedObjectModel];

if (![localCoordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil URL:[AAPLCoreDataStackManager sharedManager].storeURL
options:nil error:error])
return nil;

NSManagedObjectContext *context = [[NSManagedObjectContext alloc]
initWithConcurrencyType:NSPrivateQueueConcurrencyType];

[context setPersistentStoreCoordinator:localCoordinator];
context.undoManager = nil;

return context;
}


Then later, this context is used outside a performBlock:


NSArray *matchingQuakes = [taskContext
executeFetchRequest:matchingQuakeRequest error:anyError];


Why does this work?

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSPrivateQueueConcurrencyType working outside of performBlock

2015-07-28 Thread Trygve Inda
 
 On 28 Jul 2015, at 9:12 pm, Trygve Inda cocoa...@xericdesign.com wrote:
 
 I gather that when using NSPrivateQueueConcurrencyType, all operations (a
 fetch for example) have to be done within a performBlock call.
 
 
 ...
 
 Then later, this context is used outside a performBlock:
 
 
 NSArray *matchingQuakes = [taskContext
 executeFetchRequest:matchingQuakeRequest error:anyError];
 
 
 Why does this work?
 
 You are supposed to call performBlock so that all accesses to the MOC are
 serialized on the queue and so you get thread safety that way. However it's
 quite possible to call the methods directly on the MOC in any thread context
 and they will work, all the performBlock() actually does is queue the same
 block of code onto the dispatch queue and when it's its turn, it executes by
 calling [ moc executeFetch.. blah blah].
 
 If you do that of course you have no thread safety any more and are likely to
 blow up. In this case there's only one thread (I believe) and so the accesses
 are serialized anyway and it works. It's a bad piece of code.
 
 I filed an enhancement report requesting that the coredata stack assert if you
 called a private queue MOC method from the wrong queue, I don't recall seeing
 anything come of it, however I do remember there is quite a lot of logging you
 can turn up on CoreData and it's possible one such log will tell you you're
 doing this. 

If I do use performBlock and have to do several things:

This code is sitting inside a completion block for a URL downloader
{
[self doSomething];
[myContext performBlock (do more stuff)];
[self doSomethingElse];
}


Since the perform block will run in a different thread, how can I make sure
the do more stuff is finished before calling doSomethingElse?

Or in this case would using NSConfinementConcurrencyType be better since it
is all within a completion block and presumably on it's own thread anyway.





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSPrivateQueueConcurrencyType working outside of performBlock

2015-07-28 Thread Trygve Inda
 
 On 28 Jul 2015, at 9:12 pm, Trygve Inda cocoa...@xericdesign.com wrote:
 
 I gather that when using NSPrivateQueueConcurrencyType, all operations (a
 fetch for example) have to be done within a performBlock call.
 
 
 ...
 
 Then later, this context is used outside a performBlock:
 
 
 NSArray *matchingQuakes = [taskContext
 executeFetchRequest:matchingQuakeRequest error:anyError];
 
 
 Why does this work?
 
 You are supposed to call performBlock so that all accesses to the MOC are
 serialized on the queue and so you get thread safety that way.

So what has to be called though performBlock??

NSManagedObjectContext* privateContext = [[NSManagedObjectContext alloc]
initWithConcurrencyType:NSPrivateQueueConcurrencyType];


// Are these legal to call without using performBlock?
[privateContext setPersistentStoreCoordinator:myCoordinator];
[privateContext setUndoManager:nil];



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Custom UTI in Preference Pane

2015-06-10 Thread Trygve Inda
My Preference Pane is able to import/export data in a custom format and I'd
like to put this into a document with a specific filename extension. This
obviosuly works for apps, but is ther ea way to do it with a Pref Pane?

If the user double clicked a document, I'd want System preferences to open
and then open my prefpane with some sort of way to open (import) the
document.

Or should I just use .data as a generic extension?

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

SKPaymentTransaction, and Receipt on OS X

2015-06-07 Thread Trygve Inda
In my delegate:

-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray
*)transactions

I call: (to make sure we are on the main thread):

case SKPaymentTransactionStatePurchased:
[self
performSelectorOnMainThread:@selector(completeTransaction:)
withObject:transaction waitUntilDone:YES];
break;

Then in:

-(void)completeTransaction:(SKPaymentTransaction *)transaction
{
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];

// At this point the receipt is not always updated with the purchase...
Sometimes I have to quit the app and relaunch it.
}


How can I ensure the receipt is updated so that I can perform a check on it
to determine the subscription status?

This is Mac OS X - NOT iOS.

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: copyWithZone archive/unarchive

2015-01-30 Thread Trygve Inda
 
 On Jan 29, 2015, at 9:44 PM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 However, naming conventions expect copy to not
 be autoreleased so should the above really be:
 
 return ([copy retain]);
 
 Yes, if you're really still not using ARC ;-)
 
 —Jens

I am not using ARC - this is a large project that has existed for a long
time and I see no reason to change it.





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: copyWithZone archive/unarchive

2015-01-30 Thread Trygve Inda
 On Jan 30, 2015, at 7:26 AM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 
 On Jan 29, 2015, at 9:44 PM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 However, naming conventions expect copy to not
 be autoreleased so should the above really be:
 
 return ([copy retain]);
 
 Yes, if you're really still not using ARC ;-)
 
 —Jens
 
 I am not using ARC - this is a large project that has existed for a long
 time and I see no reason to change it.
 
 Just wanted to point out that you can adopt ARC on a per-file basis. Switching
 back and forth between them can be a bit of a mind bender, but that may be
 preferable to devoting a chunk of time to a wholesale conversion.

Do you see non-ARC code becoming obsolete? I could probably start moving it
to ARC slowly but it is hard to justify time spent on something that is not
really needed. I have not run into any serious bugs or unexplained crashes
due to messed up retain/release. (touching wood of course).

T.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

copyWithZone archive/unarchive

2015-01-29 Thread Trygve Inda
I have a custom class (MyCustomClass) and within another class I need to
have MyCustomClass be a property whereby I make a copy (vs retaining).
MyCustomClass is quite complex and so I was considering using:


-(id)copyWithZone:(NSZone *)zone
{
   MyCustomClass* copy = [NSKeyedUnarchiver
unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:self]];

 return (copy);
}

This will of course incur a performance hit for the archiving but in my case
it is not very significant. However, naming conventions expect copy to not
be autoreleased so should the above really be:

 return ([copy retain]);


?




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Any way to force a window under the menu bar?

2015-01-26 Thread Trygve Inda
 
 
 On 2015/01/26, at 14:54, Eric Schlegel eri...@apple.com wrote:
 
 Even if you force it under the menubar, you won’t see its content show up in
 the menubar; the menubar window pulls its blurred content exclusively from
 the desktop image.
 
 -eric
 But you could then create some excessive code to create and set temp desktop
 images including a slice of the window in just the right place...
 Totally not worth it, but interesting exercise.

But there is no API way to set the desktop picture on a per-screen,
per-space basis.

Trygve




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Any way to force a window under the menu bar?

2015-01-26 Thread Trygve Inda
 
 On 26 Jan 2015, at 05:39, Trygve Inda cocoa...@xericdesign.com wrote:
 
 I have created a borderless NSWindow. Is there a way to force it to appear
 under the menu bar so that the content of the window shows through the
 translucent menu bar?
 
 The OS seems to be resizing or repositioning my window to prevent it from
 sliding under the menu bar even when positioned programmatically (ie not
 dragging).
 
 I think this is done by - (NSRect)constrainFrameRect:(NSRect)frameRect
 toScreen:(NSScreen *)screen, so you could probably just override that to
 return an unchanged rect to get your window under the menu bar.

Nope - while did does prevent the window from resizing, as Eric Schlegel
mentioned, the menu bar background is derived from the desktop picture.

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Crash in libsystem_kernel.dylib`__workq_kernreturn:

2015-01-25 Thread Trygve Inda
 On Jan 25, 2015, at 12:33 , Trygve Inda cocoa...@xericdesign.com wrote:
 
 It does seem like if I remove a call to
 
 NSData* imageData = [[self myImageRep]
 representationUsingType:NSJPEGFileType properties:imageProperties];
 
 It no longer crashes, but the crash happens 3-5 seconds after this call when
 my program should be idle.
 
 It sounds like a memory management bug. What’s the context of the above line
 of code? Is it in a block? Are you using ARC?
 
 

No ARC and not in a block. I am trying to make a jpg file from a
NSBitmapImageRep which works fine, but sometimes I get a crash... Even
though the file is correctly produced.
 




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Any way to force a window under the menu bar?

2015-01-25 Thread Trygve Inda
I have created a borderless NSWindow. Is there a way to force it to appear
under the menu bar so that the content of the window shows through the
translucent menu bar?

The OS seems to be resizing or repositioning my window to prevent it from
sliding under the menu bar even when positioned programmatically (ie not
dragging).

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Crash in libsystem_kernel.dylib`__workq_kernreturn:

2015-01-25 Thread Trygve Inda
 What are you using for memory management then? Manual, GC?
 
 Sent from my iPad
 
 On 25 Jan 2015, at 22:57, Trygve Inda cocoa...@xericdesign.com wrote:
 
 On Jan 25, 2015, at 12:33 , Trygve Inda cocoa...@xericdesign.com wrote:
 
 It does seem like if I remove a call to
 
 NSData* imageData = [[self myImageRep]
 representationUsingType:NSJPEGFileType properties:imageProperties];
 
 It no longer crashes, but the crash happens 3-5 seconds after this call
 when
 my program should be idle.
 
 It sounds like a memory management bug. What’s the context of the above line
 of code? Is it in a block? Are you using ARC?
 
 No ARC and not in a block. I am trying to make a jpg file from a
 NSBitmapImageRep which works fine, but sometimes I get a crash... Even
 though the file is correctly produced.

Manual (no GC). I am also using memory-mapped files with mmap and munmap.

Trygve




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Crash in libsystem_kernel.dylib`__workq_kernreturn:

2015-01-25 Thread Trygve Inda
I am getting a very weird, random crash in:

libsystem_kernel.dylib`__workq_kernreturn:
0x7fff8381de60:  movl   $0x2000170, %eax
0x7fff8381de65:  movq   %rcx, %r10
0x7fff8381de68:  syscall
0x7fff8381de6a:  jae0x7fff8381de74; __workq_kernreturn + 20
0x7fff8381de6c:  movq   %rax, %rdi
0x7fff8381de6f:  jmp0x7fff8381a175; cerror_nocancel
0x7fff8381de74:  retq
0x7fff8381de75:  nop
0x7fff8381de76:  nop
0x7fff8381de77:  nop

How can I track this down since it does not seem to be tied to anything
specific.

It does seem like if I remove a call to

NSData* imageData = [[self myImageRep]
representationUsingType:NSJPEGFileType properties:imageProperties];

It no longer crashes, but the crash happens 3-5 seconds after this call when
my program should be idle.

Thanks Never seen anything like this and have spent several hours trying
to track it down.

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Fast Enumeration and remove elements

2015-01-18 Thread Trygve Inda
Apple says:

 It is not safe to remove, replace, or add to a mutable collection’s elements
 while enumerating through it. If you need to modify a collection during
 enumeration, you can either make a copy of the collection and enumerate using
 the copy or collect the information you require during the enumeration and
 apply the changes afterwards. The second pattern is illustrated in Listing 4.

So is this safe...

NSMutableDictionary* collection;  // keys are myID, values are MyObject

for (MyObject* object in [[self collection] allValues])
{
[collection removeObjectForKey:[object myID]];
}

It would seem that this is really enumberating the allValues array which
assuming it is only called once, represents the objects that exist at the
beginning of the for loop and removing them fro the collection dictionary is
safe.

Right?

Trygve




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

FSEventStreamCreate: BUG in libdispatch client: kevent[EVFILT_WRITE]

2015-01-17 Thread Trygve Inda
I am getting an error in the Console when shutting down a FSEvent monitor
I have verified that [self prefBundlePath] points to a valid directory (a
prefpane bundle).


BUG in libdispatch client: kevent[EVFILT_WRITE] delete: No such file or
directory - 0x2


-(void)addFileEventCallback
{
FSEventStreamContext fsStreamContext = {0, self, NULL, NULL, NULL};

fsStream = FSEventStreamCreate (kCFAllocatorDefault, FSEventCallback,
fsStreamContext, (CFArrayRef) [NSArray arrayWithObject:[self
prefBundlePath]], kFSEventStreamEventIdSinceNow, 3,
kFSEventStreamCreateFlagWatchRoot);
FSEventStreamScheduleWithRunLoop (fsStream, CFRunLoopGetCurrent(),
kCFRunLoopDefaultMode);
FSEventStreamStart (fsStream);

}


-(void)removeFileEventCallback
{
FSEventStreamStop (fsStream);
FSEventStreamUnscheduleFromRunLoop (fsStream, CFRunLoopGetCurrent(),
kCFRunLoopDefaultMode);
FSEventStreamInvalidate (fsStream);
FSEventStreamRelease (fsStream);
}


Ideas?



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: FSEventStreamCreate: BUG in libdispatch client: kevent[EVFILT_WRITE]

2015-01-17 Thread Trygve Inda
 On Jan 17, 2015, at 2:27 PM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 I am getting an error in the Console when shutting down a FSEvent monitor
 I have verified that [self prefBundlePath] points to a valid directory (a
 prefpane bundle).
 
 BUG in libdispatch client: kevent[EVFILT_WRITE] delete: No such file or
 directory - 0x2

 Ideas?
 
 Not so much a Cocoa question, but: are you sure that it's the FSEventStream
 tear-down that's causing that log message?
 
 Are both of the above methods being called on the same thread?
 
 You could try removing the call to FSEventStreamUnscheduleFromRunLoop().
 FSEventStreamInvalidate() unschedules it, too.
 
 You say that the path being monitored references a valid directory.  Is it the
 same directory as it was when you set up the FSEventStream?  That is, have you
 moved or deleted the prefpane bundle that was there and created a new one in
 its place?  If it has changed, then it's a different inode and any
 previously-opened file descriptor would not refer to the one at the path any
 more.
 
 Otherwise, can you reproduce it in a simple example program?  If so, file a
 bug report with Apple.
 
 Regards,
 Ken
 

This simple app does it too:

-(void)applicationDidFinishLaunching:(NSNotification*)notification
{

FSEventStreamReffsStream;

FSEventStreamContext fsStreamContext = {0, self, NULL, NULL, NULL};

fsStream = FSEventStreamCreate (kCFAllocatorDefault, FSMyEventCallback,
fsStreamContext, (CFArrayRef) [NSArray
arrayWithObject:@/Users/trygve/Library/PreferencePanes/MyPane.prefPane],
kFSEventStreamEventIdSinceNow, 3, kFSEventStreamCreateFlagWatchRoot);

FSEventStreamScheduleWithRunLoop (fsStream, CFRunLoopGetCurrent(),
kCFRunLoopDefaultMode);

FSEventStreamStart (fsStream);

FSEventStreamStop (fsStream);
FSEventStreamInvalidate (fsStream);
FSEventStreamRelease (fsStream);

}


void FSMyEventCallback (ConstFSEventStreamRef streamRef, void
*clientCallBackInfo, size_t numEvents, void *eventPaths, const
FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[])
{
int i = 1;
}



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSURL resourceValuesForKeys NSURLPathKey

2015-01-08 Thread Trygve Inda
I call:

NSData* bookmarkData = [url
bookmarkDataWithOptions:NSURLBookmarkCreationMinimalBookmark
includingResourceValuesForKeys:nil
relativeToURL:nil
error:inError];

And later:

NSDictionary* dict = [NSURL resourceValuesForKeys:[NSArray
arrayWithObject:NSURLPathKey] fromBookmarkData:[self bookmark]];
if (dict)
{
 path = [dict objectForKey:NSURLPathKey];
}

Path ends up with the correct value even though I passed nil above...

includingResourceValuesForKeys:nil

Is this documented behavior?

I think I should be putting NSURLPathKey in the call to create the bookmark,
but it does seem to work without it. Thoughts?




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: URLByResolvingBookmarkData not case sensitive

2015-01-06 Thread Trygve Inda
 
 On 6 Jan 2015, at 16:25, Trygve Inda cocoa...@xericdesign.com wrote:
 
 What then is the best way to do what I need?
 
 I am saving a bookmark to a file and later on I need to display the filename
 associated with that Bookmark.
 
 Currently I am getting the path and taking the last component, but it seems
 that when the filename's case has been changed by the user, that path
 received does not change so I am left with a name that does not match
 because the case is different.
 
 Sounds to me like you want to ask the URL for its NSURLLocalizedNameKey
 resource value.
 
 

This works for the file itself but how can I make sure the whole path's case
sensitivity still matches.

If I bookmark a file and the case of any folders or the file itself changes,
then later when I extract the path from the bookmark I want it to reflect
the new case of the path as it now exists.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: URLByResolvingBookmarkData not case sensitive

2015-01-06 Thread Trygve Inda
 
 On Jan 6, 2015, at 8:43 PM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 Ultimately what I need to able to do is compare a bookmark to a path.
 
 Why? Or rather, what is the reason underlying that one?

I am keeping a database of files that the user adds to a database.
Internally I keep the bookmark to each file but also cache the file's path
as it is faster to work with.

When adding new files, I need to make sure the file is not already in the
database so I compare the paths. This works well except when the case
changes. In that situation a file might be added that is already in the
database and since the bookmark is resolving to an old path (same path but
different case), the compare method fails unless it is made case
insensitive... But not all file systems are case insensitive.

So it needs to be fast... When I add a file, I might already have a few
thousand files in the database.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: URLByResolvingBookmarkData not case sensitive

2015-01-06 Thread Trygve Inda
 On Jan 6, 2015, at 7:40 PM, Kyle Sluder k...@ksluder.com wrote:
 
 On Jan 6, 2015, at 5:05 PM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 If I bookmark a file and the case of any folders or the file itself changes,
 then later when I extract the path from the bookmark I want it to reflect
 the new case of the path as it now exists.
 
 Use -[NSFileManager componentsToDisplayForPath:]. Then you don’t even need to
 canonicalize anything yourself.
 
 Yes.  Also, the components to display for a path are *not* the display name
 for each path component.  For example, the user never sees /Volumes.
 
 You should try to avoid displaying file paths to the user if at all possible.
 If you must, try using an NSPathControl.  That does additional simplification
 of the path, like starting paths inside the user's home at the home folder and
 not showing the parent directories of the home folder (e.g. /Users).
 
 If you really, really need to canonicalize a URL, you can try converting it to
 a file reference URL using -fileReferenceURL and then back to a file path URL
 using -filePathURL.  See the documentation for -fileReferenceURL for caveats.
 Also, this conversion can produce unexpected results in the face of symlinks
 and/or hard links.

Ultimately what I need to able to do is compare a bookmark to a path. I
would like to do this using NSArray's indexOfObject with a path derived from
the bookmark, but because the bookmark's path is not updated when only the
case changes, this sort of comparison will not work.

Basically I would like a method like:

[bookmarkData isEqualToPath:path]





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: URLByResolvingBookmarkData not case sensitive

2015-01-06 Thread Trygve Inda
 On 5 Jan 2015, at 10:11 AM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 I am using URLByResolvingBookmarkData .
 
 If I make a Bookmark to a file:
 
 /Volumes/Macintosh HD/Documents/MyFile.txt
 
 and later resolve it with URLByResolvingBookmarkData, I get the original path
 as expected.
 
 Then if I change the filename to MYFILE.txt in the Finder and resolve the
 bookmark again, the URL is still the mixed-case path above instead of the new
 uppercase file path.
 
 I would expect to get the current path in a case sensitive way.
 
 
 The following assumes that your problem is that the pathname hasn’t been
 updated, not that the reconstituted URL no longer gives access to the desired
 file. If the bookmark no longer works, then ignore the rest of this.
 
 
 What you expect is plausible, but it’s also plausible that it’s not in the API
 contract: The most that’s directly promised is that the bookmark will be as
 robust as possible _in gaining access_ to a volume, directory, container, or
 file. Your expectation isn’t disclaimed, but I don’t think Foundation promises
 to make good on it.
 
 So long as the grants-access promise is kept, it’s not necessary to report the
 identical URL string you’d get if you passed the current path to
 +fileURLWithPath: :
 
 * We don’t know whether alias resolution even looks at the string you
 originally put in the bookmark container. It’s an implementation detail; the
 string you gave might be kept only as a courtesy (or a last resort). We don’t
 know, and I don’t think we’re supposed to care.
 
 * In the Mac’s default case-insensitive HFS+, correcting for case is
 pointless. The string you asked the container to contain is still fit for
 purpose.
 
 * Presentation to the user don’t enter into it. Path (and URL) strings have
 never been safe for presentation to users. (To take one example, standard
 system directories are localized, but the BSD paths never change from their
 US-English names.)
 
 I’m not saying the documentation disclaims your interpretation, just that it
 leaves it open to Foundation’s doing what you’re seeing.

What then is the best way to do what I need?

I am saving a bookmark to a file and later on I need to display the filename
associated with that Bookmark.

Currently I am getting the path and taking the last component, but it seems
that when the filename's case has been changed by the user, that path
received does not change so I am left with a name that does not match
because the case is different.





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

URLByResolvingBookmarkData not case sensitive

2015-01-05 Thread Trygve Inda
I am using URLByResolvingBookmarkData .

If I make a Bookmark to a file:

/Volumes/Macintosh HD/Documents/MyFile.txt

and later resolve it with URLByResolvingBookmarkData, I get the original
path as expected.

Then if I change the filename to MYFILE.txt in the Finder and resolve the
bookmark again, the URL is still the mixed-case path above instead of the
new uppercase file path.

I would expect to get the current path in a case sensitive way.

??

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Bug in removeStatusItem

2014-12-31 Thread Trygve Inda
I am running 10.9.5 with two displays.

I call:

// Prepare status item
[self setStatusItem:[[NSStatusBar systemStatusBar]
statusItemWithLength:24]];

[statusItem setEnabled:YES];
[statusItem setHighlightMode:YES];
[statusItem setMenu:statusMenu];
[statusItem setImage:[NSImage imageNamed:kMenuIconBlackImageName]];
[statusItem setAlternateImage:[NSImage imageNamed:kMenuIconWhiteImageName]];


And later:

// Remove status item
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem];


However it only gets removed from the secondary screen. This thread:

https://devforums.apple.com/message/959387#959387

Says to use:

- (IBAction)removeStatusItem:(id)sender {

[statusBarItem setView:nil];

NSStatusBar *bar = [NSStatusBar systemStatusBar];

[bar removeStatusItem:statusBarItem];

statusBarItem = nil;

}


However, calling:

[[self statusItem] setView:nil];

Crashes my app.


Ideas?




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Predicate Row Template array within array

2014-11-30 Thread Trygve Inda
I have an array of objects that looks like:

{
   NSString*  name;
   NSDate*date;
   NSArray*   words;
}

The words array looks like:

{
   NSString*  id;
   NSString*  word;
}


I need to build a Predicate Row template to result in a way to search for
names, dates, and words. The first two are easy using basically:

[NSExpression expressionForKeyPath:@name];

template = [[NSPredicateEditorRowTemplate alloc]
initWithLeftExpressions:expressions
rightExpressionAttributeType:NSStringAttributeType
modifier:NSDirectPredicateModifier
operators:operators
options:0];

This gives me a predicate:

name CONTAINS[cd] Fred

But how can I build a row template to search for an object whose words
array contains a specific word?

Just in code it would be:

predicate = [NSPredicate predicateWithFormat:@%@ IN words, someword];

How can I apply that sort of logic to my row template so that the left
expression would be words, operators would be:

NSBeginsWithPredicateOperatorType
NSEndsWithPredicateOperatorType
NSContainsPredicateOperatorType

But that would give me:

words CONTAINS[cd] Fred

Which is not what I want.

How can I get the effect of the %@ IN words in a row template? This will
cause it to search for objects that contain a words array that contains a
specific word.

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Predicate Row Template array within array

2014-11-30 Thread Trygve Inda
{
   
NSString*  name;
NSDate*date;
NSArray*   words;
}
Objects;

The words array looks like:
{
  
NSString*  id;
NSString*  word;
}
Words;


As a follow up:

When I use a left expression of:

@words.word

And a modifier of: NSAnyPredicateModifier

My predicate ends up as:

ANY words.word CONTAINS[cd] Test

But I get:
[__NSCFString 0x61277d00 valueForUndefinedKey:]: this class is not key
value coding-compliant for the key word.

But it is.

My class has

@property (copy, readwrite)NSString* id;
@property (copy, readwrite)NSString* word;

And they are synthesized

I am not sure what class it is trying to look at since it does not indicate
that.

Any ideas?



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Xcode fonts blurry

2014-11-15 Thread Trygve Inda
 FYI, I use my 17 with my 27 Thunderbolt display and it works fine under all
 Mac operating systems from the past few years.
 
 Using it with a 15 retina MBP also works fine.  It's more readable than the
 15.
 
 This is just for reference.
 
 Is there a Thunderbolt adaptor for your 30?

It is running off the Thunderbolt port and the pixels are perfectly sharp,
but Xcode seems to use font smoothing when running on a Retina machine, even
if its windows are being shown on an external non-Retina display.

Font smoothing just makes Monaco 9 look terrible.

T.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Xcode fonts blurry

2014-11-14 Thread Trygve Inda
I have a 30 Apple Cinema Display that used to be hooked up to a 17 MBP. I
just upgraded to a 15 MBP with Retina display and have the 30 Cinema
display hooked up to it via a Dual Link Adapter.

So I have the built-in retina display and a 30 non retina display.

I am running 10.9.5.

On my old machine I used:

defaults write com.apple.dt.Xcode NSFontDefaultScreenFontSubstitutionEnabled
-bool YES

To make Monaco 9 look sharp.

That doesn't seem to work on the new Mac.

I assume that Xcode is seeing the retina display attached and not allowing
me to disable the font smoothing. All my fonts in Xcode look blurry when
running on the 30 Cinema display.

How can I make the Xcode usable again?

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Singleton or class methods?

2014-09-13 Thread Trygve Inda
I have a project that involves several different targets.

Included in all this is a set of related utility methods that need to be
used by different sections of the code. I am wondering how is the best way
to do this so that I don't have the same utility methods written in
different places.

1. I could make a class MyUtilities that consisted of the 10 or so methods
as class methods and the class would have no instance methods or instance
variables.

2. I could make a singleton that put the methods as instance methods, but
also had no instance variables.

Thoughts?

I can't really make these methods a category on anything else.

These methods are used to convert between an NSScreen, CGDirectDisplayID,
io_service_t, and a few other ways of dealing with screen identification. So
a category on NSScreen is not going to work since in some cases an NSScreen
is not known/used.

Trygve




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Crash on wake from sleep - mmap issue?

2014-08-06 Thread Trygve Inda

This crash is when trying to read from a file (130mb) that has been mmap'd.

It only happens rarely, and only when waking from sleep, but happens on both
10.8 and 10.9. It is almost like the mmap memory is not available right when
the system is woken up

Any ideas?




Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00011c4b87d1

VM Regions Near 0x11c4b87d1:
MALLOC_LARGE   00011ad9a000-00011bb73000 [ 13.8M]
rw-/rwx SM=PRV  
-- 
mapped file00012484a000-000125a54000 [ 18.0M]
rw-/rwx SM=COW  /private/var/folders/*/*.csstore

Thread 7 Crashed:
0   com.myapp0x0001000126d1 0x1 + 75473


Thread 7 crashed with X86 Thread State (64-bit):
  rax: 0x0001  rbx: 0x000104bd8c08  rcx: 0x00c8
rdx: 0x00011c4b87d1
  rdi: 0x601b57e0  rsi: 0x00010003099b  rbp: 0x000104bd8a60
rsp: 0x000104bd8a60
   r8: 0x   r9: 0x  r10: 0x00010022b6f0
r11: 0x000100041020
  r12: 0x  r13: 0x601b57e0  r14: 0x
r15: 0x00011bb73000
  rip: 0x0001000126d1  rfl: 0x00010246  cr2: 0x00011c4b87d1
  
Logical CPU: 1
Error Code:  0x0004
Trap Number: 14

External Modification Summary:
  Calls made by other processes targeting this process:
task_for_pid: 32
thread_create: 0
thread_set_state: 0
  Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
  Calls made by all processes on this machine:
task_for_pid: 21157
thread_create: 1
thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=181.1M resident=90.7M(50%)
swapped_out_or_unallocated=90.3M(50%)
Writable regions: Total=400.3M written=222.3M(56%) resident=248.1M(62%)
swapped_out=76K(0%) unallocated=152.2M(38%)
 
REGION TYPE  VIRTUAL
===  ===
CG backing stores  24.4M
CG image   88.5M
CG shared images212K
Image IO   24.4M
Kernel Alloc Once 8K
MALLOC235.7M
MALLOC (admin)   32K
Memory Tag 242   12K
SQLite page cache   256K
STACK GUARD56.0M
Stack  10.7M
VM_ALLOCATE16.4M
__DATA 22.4M
__IMAGE 528K
__LINKEDIT 66.2M
__TEXT114.8M
__UNICODE   544K
mapped file   178.6M
shared memory 4K
===  ===
TOTAL 839.6M




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: KVC, binding multiple properties, top level object

2014-07-13 Thread Trygve Inda
 
 On 12 Jul 2014, at 10:05 pm, Trygve Inda cocoa...@xericdesign.com wrote:
 
 ---someProperty (Custom NSObject)
 --propertyA (NSNumber)
 --propertyB (NSNumber)
 --propertyC (NSNumber)
 
 Properties A, B and C use a binding to connect them to a user interface item
 with something like:
 
 Bind to MyObject with key path someProperty.propertyA
 
 
 Just as a matter of interest, why do you decalre these subproperties as
 NSNumber types? Is there a reason you can't just make them the native scalar
 types they wrap (e.g. integer, float)? KVC/KVO automatically wraps scalar
 values with NSNumber or NSValue to pass them around through bindings, so you
 don't have to concern yourself with it. Usually, code is clearer if properties
 are declared as the native types. If you make them NSNumbers, how will you
 detect or prevent a value of the wrong type being passed?
 
 --Graham
 
 
 

Would using NSInteger (instead of NSNumber) still work right when doing KVC
in something like:


-(void)encodeWithCoder:(NSCoder *)coder;
{
for (NSString* key in [self propertyKeys])
[coder encodeObject:[self valueForKey:key] forKey:key];
}


What gets returned from [self valueForKey:key]? I guess the system wrapes
the NSInteger in an NSNumber?




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: KVC, binding multiple properties, top level object

2014-07-13 Thread Trygve Inda
 
 On 12 Jul 2014, at 10:05 pm, Trygve Inda cocoa...@xericdesign.com wrote:
 
 ---someProperty (Custom NSObject)
 --propertyA (NSNumber)
 --propertyB (NSNumber)
 --propertyC (NSNumber)
 
 Properties A, B and C use a binding to connect them to a user interface item
 with something like:
 
 Bind to MyObject with key path someProperty.propertyA
 
 
 Just as a matter of interest, why do you decalre these subproperties as
 NSNumber types? Is there a reason you can't just make them the native scalar
 types they wrap (e.g. integer, float)? KVC/KVO automatically wraps scalar
 values with NSNumber or NSValue to pass them around through bindings, so you
 don't have to concern yourself with it. Usually, code is clearer if properties
 are declared as the native types. If you make them NSNumbers, how will you
 detect or prevent a value of the wrong type being passed?
 
 --Graham
 
 
 

Is NSInteger treated the same way? This page does not mention it:

https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/KeyVa
lueCoding/Articles/DataTypes.html

NSNumber just seem a bit more flexible since they can be added to
dictionaries (such as in the userInfo of a Notification).

T.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: KVC, binding multiple properties, top level object

2014-07-13 Thread Trygve Inda
 
 On 14 Jul 2014, at 7:29 am, Trygve Inda cocoa...@xericdesign.com wrote:
 
 Is NSInteger treated the same way? This page does not mention it:
 
 NSInteger is a typedef for 'long', which size depends on the platform (32/64
 bit), so valueForKey: will wrap it as a NSNumber using type 'long'. That's
 safe across archives that are used in both 32 and 64 bit ISAs, though with
 loss of precision if a 64-bit archive was dearchived on 32-bit (and this might
 become a permanent loss if the data is reachived and then opened in 64-bit).
 Scalar properties that explicitly declare 'long long' would be always 64-bit.
 I doubt if this is an issue in practice.

So what is the purpose of valueForInteger ?



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: KVC, binding multiple properties, top level object

2014-07-13 Thread Trygve Inda
 
 On 14 Jul 2014, at 7:29 am, Trygve Inda cocoa...@xericdesign.com wrote:
 
 Is NSInteger treated the same way? This page does not mention it:
 
 NSInteger is a typedef for 'long', which size depends on the platform (32/64
 bit), so valueForKey: will wrap it as a NSNumber using type 'long'. That's
 safe across archives that are used in both 32 and 64 bit ISAs, though with
 loss of precision if a 64-bit archive was dearchived on 32-bit (and this might
 become a permanent loss if the data is reachived and then opened in 64-bit).
 Scalar properties that explicitly declare 'long long' would be always 64-bit.
 I doubt if this is an issue in practice.

So what is the purpose of the NSInteger access within NSNumber eg
integerValue and setIntegerValue ?


Please disregard my last message - it got sent before I could stop it.  :-)



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

KVC, binding multiple properties, top level object

2014-07-12 Thread Trygve Inda
My object layout looks like:

-MyObject (custom NSObject)
---someProperty (Custom NSObject)
--propertyA (NSNumber)
--propertyB (NSNumber)
--propertyC (NSNumber)

Properties A, B and C use a binding to connect them to a user interface item
with something like:

Bind to MyObject with key path someProperty.propertyA

If I have all three properties hooked up like this, it is easy to change the
value of one of them with [someProperty setPropertyA:newValue] which updates
in a KVC-friendly way and everything is good.

However, I would like to replace the entire someProperty object with a new
object of the same class and have all the lower level bindings see the
change in a KVC way.

Will doing [myObject setSomeProperty:newProperty] issue all the right KVC
notifications so the bound objects update their values?

I just need to update the upper-level object which has lots of bound
properties... Without having to update each property individually.

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

awakeFromNib multiple objects - all connected?

2014-07-04 Thread Trygve Inda
I have a nib that has several custom objects instantiated in it:

NIB
-ObjectA // contains outlets ABC
-ObjectB // contains outlets DEF


When object A receives awakeFromNib, I know that outlets A, B and C are
hooked up, but it is also safe to call a method in ObjectB that requires
ObjectB to have it's D, E  F outlets already hooked up?


ObjectA has an outlet to ObjectB so calliong a method in ObjectB is fine,
but ObjectB may not have received its awakeFromNib yet.

So the bottom line is:

When an object in a nib receives awakeFromNib are all the outlets throughout
the entire nib hooked up, or only those outlets in the object that is
receiving awakeFromNib?

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: awakeFromNib multiple objects - all connected?

2014-07-04 Thread Trygve Inda
 The nib is only ‘awake’ after all connections in the graph have been made.
 
 On Jul 4, 2014, at 11:18 PM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 So the bottom line is:
 
 When an object in a nib receives awakeFromNib are all the outlets throughout
 the entire nib hooked up, or only those outlets in the object that is
 receiving awakeFromNib?
 
 

I am just wondering which way is true:

1) all the nib's objects are connected to their outlets and then each object
is sent an awakeFromNib.

2) each object gets its own outlets connected and then is sent awakeFromNob
(so objects that have not yet received awakeFromNib may not have their
objects hooked up).




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: awakeFromNib multiple objects - all connected?

2014-07-04 Thread Trygve Inda
 
 On Jul 4, 2014, at 8:18 PM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 When an object in a nib receives awakeFromNib are all the outlets throughout
 the entire nib hooked up, or only those outlets in the object that is
 receiving awakeFromNib?
 
 All the outlets are hooked up. But not all the other objects in the nib have
 run their -awakeFromNib methods yet, so you have to be cautious about calling
 into other objects in the nib during your -awakeFromNib implementation.
 
 —Jens

That's fine. My situation is I have a subclass of NSWindowController and
several custom objects:

Owner (MyWindowController)

ControllerA

ControllerB
ControllerC

These are all in the nib and I call init in such a way that Owner is passed
a reference which it stores. When ControllerA gets an awakeFromNib it needs
to call methods in ControllerB and ControllerC that require all the outlets
to be hooked up.

I need to ensure ControllerA runs first so I do this by having an
awakeFromNib in ControllerA, but not in B or C. So that when ControllerA
gets awakeFromNib, it can manage things.

As long as A can call into B  C and know that B  C have their outlets
hooked up, that's fine.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: awakeFromNib multiple objects - all connected?

2014-07-04 Thread Trygve Inda
 
 On 5 Jul 2014, at 1:56 pm, Trygve Inda cocoa...@xericdesign.com wrote:
 
 As long as A can call into B  C and know that B  C have their outlets
 hooked up, that's fine.
 
 You can rely on all outlets being connected. What you can't rely on is the
 order in which each object's -awakeFromNib is called.
 
 --Graham
 
 
 

Perfect.

And long as one object can receive awakeFromNib, call into another objects
(via an outlet) and THOSE objects will have their outlets connected (even
though they may not have received their own awakeFromNib yet), that will
work.

Thanks!



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

App Store, Sandbox and loadable code bundle

2014-06-23 Thread Trygve Inda
I have an app that normally exists as a System Preference Pane. To get it to
work in an app, and share the same code as the prefPane, I built a small
host app that simply loads the prefPane (a Mach-O bundle) with:

[self setPaneObject:[[[paneClass alloc] initWithBundle:paneBundle]
autorelease]];
if ([paneObject loadMainView])
{
[paneObject willSelect];

 // Add view to window and adjust size
 [window setContentSize:[[paneObject mainView] frame].size];
 [window setContentView:[paneObject mainView]];
 [window center];
 [window makeKeyAndOrderFront:self];

 [paneObject didSelect];
}


Both the app and the .bundle are codesigned. The .bundle resides within the
host app's package and the whole thing is sandboxed.

It works fine on my system, but is there any reason Apple will not approve
of this? The Mach-O code bundle gets loaded into the main app and becomes
part of it.

Has anyone submitted something to the App Store that works like this?

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: FSPathMakeRef deprecated - replacement for LSSetItemAttribute?

2014-06-22 Thread Trygve Inda
 On 22 Jun 2014, at 00:20, Trygve Inda cocoa...@xericdesign.com wrote:
 FSPathMakeRef is deprecated in 10.8, but LSSetItemAttribute requires an
 FSRef. Is there a correct way to create an FSRef or perhaps there is a
 replacement for LSSetItemAttribute to modernize:
 
 LSSetItemAttribute(fsRef, kLSRolesAll, kLSItemQuarantineProperties, NULL);
 
 Check out the headers for this call in Xcode 6, the comments there mention
 what call to use instead.
 
 Cheers,
 -- Uli Kusterer
 “The Witnesses of TeachText are everywhere...”
 http://zathras.de
 
 

Yes they do, but not what parameters to pass to it.





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Sandboxing, AppleEvents (or other IAC method)

2014-06-22 Thread Trygve Inda
I have an app that was easy to get into the pre-sandbox App Store and am
trying to find a way to get it back in there.

There are actually two apps.. A GUI and a Renderer.

The GUI controls all the settings, starts and stops the renderer and, while
the renderer is running, sends messages to the renderer to make changes as
the user manipulates the GUI.

The main GUI currently uses Distributed Notifications to talk to the
renderer. These aren't allowed in the sandbox, but could be replaced with
AppleEvents. I am a bit reluctant to do this because the AppleEvent
entitlements are listed as temporary.

I have read about XPC, but the docs say The life cycle of an XPC service,
and its integration with Grand Central Dispatch (GCD), is managed entirely
by the system.

My renderer process would need to be running even after the user has quit
the GUI, so I am not sure that this sort of system will work in my case.

Additionally I have an NSStatusItem that runs within its own app and needs
to work similarly to the GUI, sending messages to the renderer when the GUI
app is not running.

Should I use AppleEvents, or just forget trying to put such a complex web of
3 apps into a sandbox?

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

FSPathMakeRef deprecated - replacement for LSSetItemAttribute?

2014-06-21 Thread Trygve Inda
FSPathMakeRef is deprecated in 10.8, but LSSetItemAttribute requires an
FSRef. Is there a correct way to create an FSRef or perhaps there is a
replacement for LSSetItemAttribute to modernize:

LSSetItemAttribute(fsRef, kLSRolesAll, kLSItemQuarantineProperties, NULL);

Thoughts?



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Send msg to object by nameed NSString;

2014-06-20 Thread Trygve Inda

 I would think 'copy' would still be ok with this (for example in the case of
 NSStrings) since that should still be released. For 'assign' I can see the
 advantage.
 
 It’s not just an advantage, it’s avoiding a crasher, most likely, and where
 it’s not, it’s avoiding silently corrupting an object graph. [(id)someInt
 release] is not a message you want to ever find yourself sending.
 
 So this would be better?
 
 for (NSString* key in [self propertyKeys])
 [self setValue:nil forKey:key];
 
 
 No, because unless you also override -setNilValueForKey: for your classes that
 do this, you will raise an NSInvalidArgumentException.


None of my properties are ints, doubles, longs or any other non-object type.
This class is really a replacement for just using an NSMutableDictionary to
store this stuff. All the properties are NSNumber, NSString or NSColor

Trygve




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Send msg to object by nameed NSString;

2014-06-19 Thread Trygve Inda
 
 On 19 Jun 2014, at 3:30 pm, Trygve Inda cocoa...@xericdesign.com wrote:
 
 Should I be doing:
 
 self.myProperty = [coder decodeObjectForKey:kMyProperty];
 
 (isn't that effectively the same as a getter/setter)?
 
 Yep, it's the same, so you will gain nothing there.
 
 
 Guessing it would be better as:
 
 myProperty = [[coder decodeObjectForKey:kMyProperty] retain];
 
 
 Yes, this is what I meant. If you have declared your own ivars, it's far
 faster to set them directly.
 
 
 100x - 600x is a big hit.
 
 It only starts to become noticeable when you are dearchiving a big graph
 though, so don't sweat it for one object. If you are relying on synthesizing
 the actual ivar, not just the setters/getters, you have little choice, though
 apparently you can rely on the ivar being the name of the property with a
 leading underscore. I dislike that sort of hidden magic however.
 
 I saw one file come down from taking 11 minutes (!) to 1.5 seconds to open
 with just this change.
 
 
 --Graham
 
 
 


I declare all my ivars but this case is small so I can't imagine an
improvement. I have one other place where it might help though. That one
takes about 2-3 seconds to open/read a file.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Send msg to object by nameed NSString;

2014-06-18 Thread Trygve Inda
If I have a class:

@interface MyClass : NSObject
{
NSNumber*myNumber;
}
@property (nonatomic, retain) NSNumber* myNumber;


And in the class implementation I have:

-(void)doSomething
{
// it could get this string from anywhere, not always a constant
NSString* myString = @myNumber;

 ???
}


Is there a way to access the myNumber property and send it a message knowing
only it's name (contained in myString)?

So rather than doing:

[myNumber release];

I could do something like:

[getProperty(myString) release];


Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Send msg to object by nameed NSString;

2014-06-18 Thread Trygve Inda
 
 On 19 Jun 2014, at 4:53 am, Daniel DeCovnick danhd...@mac.com wrote:
 
 Yes. You can either use key-value coding: [[self valueForKey:myString]
 release];
 
 
 [value release];
 
 
 
 These invocations of -release appear to be erroneous. Why do you have them
 there? If you think they should be there as a matter of routine, your
 understanding of memory management is probably faulty.
 
 --Graham
 

The reason for this is I have several classes with only properties (no
methods other than getters/setters created with synthesize).

The method propertyKeys (below) is used to simplify and shorten the code in
these classes since I want to encode/decode and (upon dealloc), release all
the properties.

In the example below there is only one property, but in reality there are
many.


The interface looks like:

@interface MyClass : NSObject NSCoding
{
  NSNumber* someValue;
}
@property (nonatomic, retain) NSNumber* someValue;


The implementation looks like:

@implementation MyClass

@synthesize someValue;

-(id)init
{
if (self = [super init])
{
   [self setSomeValue:[NSNumber numberWithInt:3];
}
return self;
}


-(void)dealloc
{
for (NSString* key in [self propertyKeys])
[[self valueForKey:key] release];

[super dealloc];
}


-(id)initWithCoder:(NSCoder *)coder
{
if (self = [self init])
{
for (NSString* key in [self propertyKeys])
{
if ([coder containsValueForKey:key])
[self setValue:[coder decodeObjectForKey:key] forKey:key];
}
}
return (self);
}


-(void)encodeWithCoder:(NSCoder *)coder;
{
for (NSString* key in [self propertyKeys])
[coder encodeObject:[self valueForKey:key] forKey:key];
}


-(NSArray *)propertyKeys
{
NSMutableArray* propertyKeyArray =
[[[NSMutableArray alloc] init] autorelease];

unsigned int outCount, i;

objc_property_t* properties =
class_copyPropertyList([self class], outCount);

if (properties)
{
for(i = 0; i  outCount; i++)
{
objc_property_t property = properties[i];
const char* propName = property_getName(property);
if(propName)
{
NSString* propertyName =
[NSString stringWithUTF8String:propName];
[propertyKeyArray addObject:propertyName];
}
}
free(properties);
}
return (propertyKeyArray);
}



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Send msg to object by nameed NSString;

2014-06-18 Thread Trygve Inda
 
 On 19 Jun 2014, at 10:57 am, Trygve Inda cocoa...@xericdesign.com wrote:
 
 The method propertyKeys (below) is used to simplify and shorten the code in
 these classes since I want to encode/decode and (upon dealloc), release all
 the properties.
 
 
 -(void)dealloc
 {
for (NSString* key in [self propertyKeys])
[[self valueForKey:key] release];
 
 

 Ideally, your -dealloc method should mirror your -init method, so that you
 have each property set to nil listed individually, just as -init sets each one
 individually. Sure, that's tedious if you have hundreds of properties, but
 it's at least reliable with no nasty surprises. If you are determined to
 iterate a list, then at least use the setter, passing nil, rather than the
 getter, and calling release. (That also allows you to change a property to
 'assign' or 'copy' if necessary without creating a bug).


I would think 'copy' would still be ok with this (for example in the case of
NSStrings) since that should still be released. For 'assign' I can see the
advantage.

So this would be better?

for (NSString* key in [self propertyKeys])
 [self setValue:nil forKey:key];


I can't at all see how I would ever subclass this, but I'll certainly give
the rest of your post some serious thought. Obviously if I ever do need to
subclass, I'll have to revert to listing each property on its own for
code/decode and dealloc.

Thanks,

Trygve





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Send msg to object by nameed NSString;

2014-06-18 Thread Trygve Inda
 
 A performance related argument: using property getters and setters in
 -initWithCoder: and -encodeWithCoder: can bring with them serious performance
 issues. Might not matter in your case, or in most cases, but it really adds up
 if you have a large and complex object graph. A recent exercise to set ivars
 directly in -initWithCoder: instead of using property setters saw a 100 - 600x
 speed improvement when reading a file for a graph with ~10,000 objects. Just
 sayin'.

Should I be doing:

self.myProperty = [coder decodeObjectForKey:kMyProperty];

(isn't that effectively the same as a getter/setter)?

Guessing it would be better as:

myProperty = [[coder decodeObjectForKey:kMyProperty] retain];

100x - 600x is a big hit.

Trygve




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Dictionaries or custom class containing no methods?

2014-06-17 Thread Trygve Inda
I need to store a large collection of settings (not application preferences,
but parameters describing how complex data is to be displayed) and am
looking for pros/cons as to the best way.

At the top I have a class called MySettings. Within this I need to have
groups of related settings. They can either be NSMutableDictionary or a
custom class containing properties, but no methods.

@interface MySettings : NSObject
{
MySettingsAppearance*appearance;  // size, graphic style etc.
MySettingsColors*colors;  // colors for different elements
MySettingsLocations* locations;   // array of data

... About 8 more like these ...
}


In this way I could do something like:

[[settings appearance] width]
[[settings colors] centerline]
[[[settings locations] allLocations] objectAtIndex:i]

Alternatively I could do:

@interface MySettings : NSObject
{
NSMutableDictionary*appearance;  // size, graphic style etc.
NSMutableDictionary*colors;  // colors for different elements
NSMutableDictionary*locations;   // array of data

... About 8 more like these ...
}


[[settings appearance] objectForKey:kSettingsAppearanceWidth]
[[settings colors] objectForKey:kSettingsColorCenterline]
[[[settings locations] objectForKey:kSettingsLocationsAll] objectAtIndex:i]


All the data in the dictionaries (or custom property-only classes) will be
standard types: NSNumber, NSData, NSString, NSColor (which will have to be
archived to convert it to NSData for saving).

Thoughts on the pros and cons of both methods?

It feels weird to create a class that has zero methods (other than
getters/setters).

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

  1   2   3   4   5   >