How to mix Check boxes and Radio buttons in NSOutlineView?

2008-06-13 Thread John
Hi,
I have a two level hierarchy displayed in NSOutlineView.
Currently all items have check boxes, but I have a request
to replace check boxes by radio buttons in some branches 
of the hierarchy, where only one item can be checked at a time.
Other branches should keep check boxes, which allow checking
any number of items.

I tried to call [cell setButtonType:NSRadioButton];
in - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell 
forTableColumn:(NSTableColumn *)tableColumn item:(id)item
but that had no effect - check boxes are still displayed.

What else can I do?

Thank you
Bill


  
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Cocoa Apple Script Problem

2008-12-19 Thread john
Hi John-

If you are on Leopard, try taking a look at the documentation for the
following method:

- (id)newScriptingObjectOfClass:(Class)class forValueForKey:(NSString *)key
withContentsValue:(id)contentsValue properties:(NSDictionary *)properties;

The Cocoa Scripting Guide refers to the Leopard Foundation Release Notes in
a number of places for the latest info, and that I where I found out about
this method
(http://developer.apple.com/releasenotes/Cocoa/Foundation.html#Scripting). 
In short, one implements this method on the containing object, which then
allows you to read the properties dictionary and configure your newly made
object before it gets added (via insertObject:inAtIndex:) to the
container object.

There is a lot of new scripting material in those release notes; should be
helpful to your scripting efforts.  Hope this helps!

John

Positive Spin Media
http://www.positivespinmedia.com

On Fri, 19 Dec 2008 10:11:19 -0800, John Nairn  wrote:
> I have implemented the required methods to support creating an object  
> in Apple Script, but it does not work as advertised.
> 
> This does work as expected
> 
>   tell front document
>   make new family at end
>   tell last family
>   set properties to {husband:"@I5@"}
>   end tell
>   end tell
> 
> This creates the object but does NOT set the properties
> 
>   tell front document
>   make new family at end with properties {husband:"@I5@"}
>   end tell
> 
> The family objects are tied to key-value methods using  =  
> famRecords in my suite and the method getting called by both these  
> make commands is
> 
> - (void)insertInFamRecords:(id)object
> 
> where object is the correct FAMRecord type. If "set properties to"  
> works on an existing object, shouldn't it work when creating a new  
> one? Do have to manuul find a way to override the make command?
> 
> Curiously this method of form insertInRecords: is not even  
> mentioned in the "Key-Value Coding and Cocoa Scripting" section of  
> the "Cocoa Scripting Guide." I had to find it by an error message in  
> the Console before it was present.
> 
> ---
> John Nairn
> GEDitCOM - Genealogy Software for the Macintosh
> http://www.geditcom.com


___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


RE: Safari-like tabs in my own app?

2009-01-26 Thread john
Hi Ulai-

All of the palette instructions are for Interface Builder 2 - the new IB3
has a different plug-in architecture.  You will have to use the framework
and a custom view in IB with the more modern tools (until someone crafts up
an IB3 plugin :-)

It does have the "merge" behavior you seek, depending on which tab style
you assign to the control.  There are a number of apps using the control to
that effect.  Adium is probably the most notable of the group, and it is
their people who maintain the latest version at googlecode.

I was the original author of the control, and you can see it in action
(merged and all) in Pandora:
http://www.positivespinmedia.com/shareware/Pandora/

It has since been much improved, and I'm a little out of touch with it -
sorry I can't be of more help!

John



On Mon, 26 Jan 2009 22:17:21 +, Ulai Beekam 
wrote:
>> Check out PSMTabBarControl over on googlecode:
>>
>> http://code.google.com/p/maccode/wiki/WhatIsMacCode
>>
>> Dave
> 
> Hmm ok. I checked that out but the palette refused to appear in Interface
> Builder. I followed their directions and put PSMTabBarControl.palette
> folder into ~/Library/Palettes/ folder but no palettes appears in
Inteface
> Builder even after restarting IB. Any ideas?
> 
> 
> Anyway, assuming if I want to make my own tab implementation, what
> mechanism do I use to "merge" my custom view into the toolbar, meaning
that
> the bottom border of the toolbar disappears in areas where my custom view
> is directly below the toolbar (this may not necessarily be all the
> horizontal space due to source lists to the left etc.) Can a custom view
> affect its neighboring toolbar like that in some way?
> 
> 
> About PSMTabBarControl, anyone here has any experience with it? Does it
> "merge" in the toolbar like it should?
> 
> 
> And again about that Xtorrent image I posted earlier
> (http://www.xtorrentp2p.com/1.png), what do you reckon he uses for tabs?
> You think he's using PSMTabBarControl?
> _
> News, entertainment and everything you care about at Live.com. Get it
now!
>
http://www.live.com/getstarted.aspx___
> 
> 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:
>
http://lists.apple.com/mailman/options/cocoa-dev/john%40positivespinmedia.com
> 
> This email sent to j...@positivespinmedia.com
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Identifying a specific Mac model

2015-09-13 Thread John Daniel
Hello,
Does anyone know of an API or utility that will identify specific Mac models? 
The “Model Identifier” like “MacBook8,1” is not sufficient to uniquely describe 
a model. MacBook8,1 covers all colours of the new  MacBook. I am trying to 
differentiate the silver, from the space grey, from the gold.

My app has an animation where it cycles through various Macs like a slot 
machine, finally landing on the user’s specific machine. I used to just look at 
the “Model Identifier”. I could pretty easily identify the matching machine 
image from /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources. 

However, the images for the new retina MacBook are in a different location. I 
found where they live in an apparently randomly-named framework, but I still 
can’t connect a specific image with the user’s specific machine. There is a 
private API for the UIDevice class in iOS that provides similar information. Is 
there anything like this for the Mac?

Thanks,

John Daniel


___

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: Identifying a specific Mac model

2015-09-14 Thread John Daniel
Thanks for the responses. Unfortunately, Apple is way ahead of all of us.

The “Model Identifier” (MacBook8,1 et al.) is not sufficient to identify a 
particular model. It only identifies general families of models. All you have 
to do is go to My OWC (http://eshop.macsales.com/MyOWC/ 
<http://eshop.macsales.com/MyOWC/>), pick MacBook Pro, and look at the options. 

The system images are where they should be. I don’t understand Apple’s 
reasoning, but that is where Apple wants them. 

I don’t know if Apple even tracks the colour of the retina MacBooks. I don’t 
have one myself. I haven’t been able to find a serial number online. The serial 
number generator scripts posted online don’t generate valid serial numbers for 
this model. 

Scraping the Apple self-service warranty page might work, but I don’t have any 
MacBook serial numbers for testing. I really don’t want to parse HTML. Even so, 
people seem to treat serial numbers as personal information and might freak out 
if I start sending them over the internet. If I had a few serial numbers for 
testing, I would know more - or at least something.

I do extract the last 4 characters and send them to Apple’s support web 
services to get the “marketing name” like "MacBook (Retina, 12-inch, Early 
2015)”. But those names don’t seem to include colour. I know of a few different 
queries for Apple’s services for technical specifications, possible memory 
upgrades, OS name, and this marketing name. This is a true web service that 
returns parseable XML. I don’t know if there is any query that will give me the 
machine icon.

John Daniel

___

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: Identifying a specific Mac model

2015-09-15 Thread John Daniel
Thanks! That did the trick. It took a couple of tries to get it working. I 
forgot that the namedImage method returns a scaled down image. it is a little 
counter-intuitive, but you have to scale the image up and then it will pick the 
bigger image in the icns file.

I still don’t know if it will display in gold on a new MacBook, but it seems to 
work on two MacBookPros and an iMac.

John Daniel
i...@etresoft.com



> On Sep 14, 2015, at 12:43 PM, Jean-Daniel Dupas  wrote:
> 
> If you just want to current machine icon, just use + [NSImage 
> imageNamed:NSImageNameComputer]
> 
> 


___

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: Identifying a specific Mac model

2015-09-15 Thread John Daniel
There is a gold icon in the system. I am hopeful that this method will retrieve 
it, if running on a gold MacBook. If not, people are reporting that it at least 
displays a silver MacBook icon and that’s as good as I can do on my own.

John Daniel

> On Sep 15, 2015, at 2:54 PM, Marek Hrušovský  wrote:
> 
> I am just curious, is there a gold icon in the system or it's a guess that 
> there should be one ?
> 


___

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: Identifying a specific Mac model

2015-09-15 Thread John Daniel
Sure. The path to the new MacBook images is 
/System/Library/CoreServices/CoreTypes.bundle/Contents/Library/MJTlrL7BTqUr.bundle

However, it would be impossible for me to inspect this. Because I am using this 
system function, I could only see it go into this new bundle if I was running 
it on a new MacBook. It does seem to work, but my confidence is based more on 
faith than works.

John Daniel
i...@etresoft.com



> On Sep 15, 2015, at 4:16 PM, Marek Hrušovský  wrote:
> 
> Can you please tell us the path? 
> You can load it with mentioned method, then fire Activity, hit the inspect 
> button on the process  (sample one line app that shows the icon in imageview) 
> and one of those lines should be the icon.
> Many thanks. 
> 
> On Tue, Sep 15, 2015 at 8:58 PM, John Daniel  <mailto:etresoft.apple.li...@icloud.com>> wrote:
> There is a gold icon in the system. I am hopeful that this method will 
> retrieve it, if running on a gold MacBook. If not, people are reporting that 
> it at least displays a silver MacBook icon and that’s as good as I can do on 
> my own.
> 
> John Daniel
> 
> > On Sep 15, 2015, at 2:54 PM, Marek Hrušovský  > <mailto:xhrus...@gmail.com>> wrote:
> >
> > I am just curious, is there a gold icon in the system or it's a guess that 
> > there should be one ?
> >
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com 
> <mailto: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 
> <http://lists.apple.com/>
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/xhruso00%40gmail.com 
> <https://lists.apple.com/mailman/options/cocoa-dev/xhruso00%40gmail.com>
> 
> This email sent to xhrus...@gmail.com <mailto:xhrus...@gmail.com>

___

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: Error unwrapping an optional which isn't an optional

2015-09-21 Thread John Daniel
I think the optional in question is the IB object. You may be accessing this 
property before your nib is completely setup. 

John Daniel
Sent from my iPad
___

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: -[NSThread start] blocks ?!?

2015-09-27 Thread John Daniel

> In a OS X app, predating Grand Central Dispatch, in the main thread, I create 
> and start a new thread
> 
> NSThread* worker ;
> worker = [[NSThread alloc] initWithTarget:instance
> selector:@selector(beginWithInfo:)
>   object:info] ;
> [worker setName:@“My Worker thread"] ;
> [worker start] ;
> 
> usually this works OK, but sometimes, possibly when the above code executes a 
> second or third time in rapid succession, [worker start] will block forever:

There is no way to tell what is causing the deadlock without knowing exactly 
what is happening relating to:
1) instance
2) beginWithInfo:
3) info

If this code pre-dates GCD, you could have all kinds of nasty stuff going on. 
All of the items I listed above are shared. They may, or may not, need to be 
protected by locks. There is no way to tell without dumping virtually your 
entire program.

I strongly suggest looking into adopting GCD instead. It dates to 10.5, so you 
aren’t giving up too much backwards compatibility. Data sharing using serial 
queues is safer and more robust by design. You will still need to ensure that 
any shared access uses that serial queue, but I find GCD much more 
straightforward. You may end up blocked in a semaphore again, but it will be 
your own semaphore and you can more easily debug it.

John Daniel


___

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: -[NSThread start] blocks ?!?

2015-09-28 Thread John Daniel
> On Sep 28, 2015, at 12:13 AM, cocoa-dev-requ...@lists.apple.com 
> <mailto:cocoa-dev-requ...@lists.apple.com> wrote:
> 
> Thank you, John.  You are referring to what my secondary thread is doing.  My 
> point is that if we can’t at least rely on -[NSThread start] returning before 
> the secondary starts, there is no way for a seconary thread to call back to 
> the main thread without possibility of deadlock.  It’s a defect in NSThread.
> 
>> Data sharing using serial queues is safer and more robust by design.
> 
> OK, if it is a defect in NSThread, GCD might not have this defect.  I’ll 
> consider that. Thank you.

It is not a defect in NSThread. That is just a subtlety the way it works. In 
this model, there are three potential situations when -[NSThread start] returns:
1) Your thread hasn’t started yet
2) Your thread has started and is running
3) Your thread has completed

Your code must handle all of these possibilities. 

GCD is just a different model and has different subtleties. GCD may not spawn 
any new “threads” at all. You would think in terms of queues and blocks 
instead. 

GCD encourages a more straightforward producer-consumer architecture. You can 
use that architecture for your NSThread code too and get more robust behaviour. 
In general, you really don’t want to think about what your threads might or 
might not be doing or what state they might be in. Use locks around any 
structures that could be shared. Use semaphores to enforce any sequential 
behaviour if you need that.


John Daniel
i...@etresoft.com <mailto:i...@etresoft.com>





John Daniel
i...@etresoft.com



___

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: NSThread subclass get blocked on 'start' method call

2015-09-28 Thread John Daniel
> On Sep 28, 2015, at 3:00 PM, cocoa-dev-requ...@lists.apple.com wrote:
> 
> I have problem with NSThread subclass. It's very similar to this case - 
> http://prod.lists.apple.com/archives/cocoa-dev/2015/Sep/msg00454.html 
> <http://prod.lists.apple.com/archives/cocoa-dev/2015/Sep/msg00454.html>.
> I have a library, that provide developer-friendly interface to 
> AddressBook.framework. And I unable to use GCD for thread safety, because of 
> `ABAddressBookRegisterExternalChangeCallback` function, that requires a run 
> loop to schedule callback. 
> So I decided to use NSThread subclass. And found that second NSThread 
> instance blocks main thread on `start` method call.
> Here is the source code of Example - 
> https://www.dropbox.com/s/r5k8o28pocu7afk/aptest.zip?dl=0 
> <https://www.dropbox.com/s/r5k8o28pocu7afk/aptest.zip?dl=0>
> When you press 'load contacts' for the second time, it'll block main thread 
> with `semaphore_wait_trap`
> Any ideas?

Why are you using threads at all? If there is a run loop callback, that 
probably means you should schedule it on the run loop. Don’t introduce 
threading unless you are doing something in that callback that blocks the UI. 
Even then, schedule your callback on the UI run loop and have your callback 
spawn the thread or async block.

And that API is deprecated in iOS9 anyway. If you don’t need to support iOS 8 
or earlier, use the new Contacts API.

John Daniel

___

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: New warning in Xcode 7

2015-10-13 Thread John McCall
> On Oct 13, 2015, at 3:24 PM, Graham Cox  wrote:
> In a piece of code I haven’t worked on in a while, I’m suddenly getting a new 
> warning which I’ve never seen before:
> 
> “Multiple unsequenced modifications to ‘ix’”
> 
> Code is:
> 
> 
> ix = ++ix % guess.count;
> 
> where ix is a NSUInteger.
> 
> Is this telling me that the order of the preincrement and the mod operation 
> is undefined? Surely a preincrement is defined to happen first, that’s why 
> it’s called a PREincrement? Or does the warning refer to something else? I’ve 
> used this form of expression for years without any issues, why is it suddenly 
> one?

Pre-increment is defined to return the value that would be stored in its 
operand.  The actual store to the operand is indeterminately sequenced with 
returning that value, however.

John.



___

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: Assigning an element of a swift array to a userdata parameter triggers didSet

2015-11-18 Thread John McCall
> On Nov 18, 2015, at 11:12 AM, Quincey Morris 
>  wrote:
> On Nov 18, 2015, at 10:57 , Jens Alfke  wrote:
>> 
>> Doesn’t the pointer become invalid as soon as myElement goes out of scope? 
>> (There’s a reason that type is called *Unsafe*Pointer…)
> 
> Yes, but so does &myArray[0] in the original code. According to your 
> hypothesis, it’s copied into a temporary, which also becomes invalid as soon 
> as the current scope ends.

It’s actually shorter than that; inout temporaries are valid just for the 
duration of the call.

Going back to your actual problem: “user data” parameters like this are really 
just pointer-sized opaque buckets of bits.  Assuming your array is, in fact, 
stably-indexed (and if it isn’t, passing a pointer won’t work either!), 
consider just passing an index as the user data; you can construct a pointer 
from an Int like this:
  UnsafePointer(bitPattern: i)
and get the Int back like this:
  unsafeBitCast(ptr, Int.self)

The fact that the latter is apparently the only interface for getting back to 
an Int is probably a bug.

John.
___

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

AppleEvents: Send port for process has no send right, port=( port:37207/0x9157 rcv:1,send:0,d:0 limit:5) (findOrCreate()/AEMachUtils.cp #526)

2015-11-21 Thread John MacMullin
Anyone have an idea of what is causing this message in the log file?

AppleEvents: Send port for process has no send right, port=( port:37207/0x9157 
rcv:1,send:0,d:0 limit:5) (findOrCreate()/AEMachUtils.cp #526)

I am using scripting bridge for several Apple program interfaces.

Best regards,

John MacMullin
___

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

Hurdles in converting to Swift

2015-12-23 Thread John Brownie
I have a fairly simple iOS application that was working in Objective-C, 
and which I've now rewritten in Swift, by rewriting each class and 
removing the old .m and .h files, and keeping the storyboard. However, 
it falls over immediately with the console message:


2015-12-24 10:43:40.664 AppName[10464:1086828] Unknown class 
SearchViewController in Interface Builder file.


After that, it crashes with an uncaught exception (which looks like it's 
related to the above):


2015-12-24 10:43:40.707 AppName[10464:1086828] *** Terminating app due 
to uncaught exception 'NSUnknownKeyException', reason: 
'[ setValue:forUndefinedKey:]: this class 
is not key value coding-compliant for the key activityIndicator.'


Of course, there is an appropriate class called SearchViewController in 
the application, and it has an outlet activityIndicator, and it's set as 
the class for one scene. I've cleaned the build folder, but it still 
happens.


Any wisdom on how to proceed?

John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics, Ukarumpa, Eastern Highlands Province, 
Papua New Guinea

Mussau-Emira language, Mussau Island, New Ireland Province, Papua New Guinea
___

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: Hurdles in converting to Swift

2015-12-23 Thread John Brownie

___

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: Hurdles in converting to Swift

2015-12-24 Thread John Brownie

On 24/12/2015 11:49, Quincey Morris wrote:

On Dec 23, 2015, at 17:38 , John Brownie mailto:john_brow...@sil.org>> wrote:

2015-12-24 10:43:40.664 AppName[10464:1086828] Unknown class 
SearchViewController in Interface Builder file.

Try going to the inspector in IB and remove the class name 
SearchViewController, and make sure both the class and module fields are empty. 
Then choose the class name from the popup menu beside the text field.

In the current version of Xcode, the module field should say “Current — ” in gray.  IIRC in older versions, you needed to choose/type the 
module name explicitly.

(I went the long way around, but I suspect your problem is that the Swift 
module name is missing, which is causing IB to assume the view controller class 
is an Obj-C class name.)

It looks as though my original reply didn't make it, but this was the 
problem, and both following Quincey's instructions and directly 
selecting my app's name in the module field worked to make it all 
running correctly again.


Thanks to Quincey and others who offered suggestions!

John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics, Ukarumpa, Eastern Highlands Province, 
Papua New Guinea

Mussau-Emira language, Mussau Island, New Ireland Province, Papua New Guinea
___

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: Why doesn't SMJobBless sample work?

2016-01-11 Thread John Brownie

On 11/01/2016 18:44, Motti Shneor wrote:

Hi. Excuse this novice question (I see previous questions relating to 
SMJobBless that start off where I need to finish…)

I need to develop an OS-X daemon (in c++) that must run privileged. I intend to 
deploy it embedded in a System-Preferences panel, that will launch it using the 
SMJobBless() API.

Naturally, I read Apple “Deamons and Services programming guide” (which left me 
with more questions than I initially had) and downloaded the simple but 
enlightening “SMJobBless” sample project.

Alas - the sample doesn’t function. It builds, runs and the application asks me 
for admin credentials, then it always spits the same error:


2016-01-11 10:35:52.580 SMJobBlessApp[83383:3929331] Something went wrong! 
CFErrorDomainLaunchd / 4

I started thinking there should be some specific code-signing involved, to 
allow one application to launch privileged daemon, but nothing is documented 
about this both in the sample itself, nor in the SMJobBless() API referene.

I started playing with signing both the App and the daemon with my own 
developer ID (the sample project itself has no code-signing defined for the 
application, and some arbitrary code-signing set for the daemon itself).

(I also found and examined 3 or 4 other related code-samples, that seem to be 
based on this, some with XPC communications between the app and its daemon, 
some without) but all give that exact same error message above, when the app 
attempts to SMJobBless() its daemon.

Now — any heads-up or hint will be greatly appreciated.


You want the Even Better Authorization Sample Code rather than SMJobBless.

John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics, Ukarumpa, Eastern Highlands Province, 
Papua New Guinea

Mussau-Emira language, Mussau Island, New Ireland Province, Papua New Guinea
___

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: Cocoa-dev Digest, Vol 13, Issue 14

2016-01-11 Thread John Brownie

On 12/01/2016 14:08, Eden Smallwood wrote:

On 11/01/2016 18:44, Motti Shneor wrote:
You want the Even Better Authorization Sample Code rather than SMJobBless.

John

I don't think he does.

The E. B. A. S. C. relies on AEWP, which is utterly, hopelessly, 
unspeakably deprecated.

He does in fact want to use SMJobBless, which is Apple's current, and only, 
blessed paradigm for executing tasks with elevated privileges from a "normal" 
app.

The problem with "SMJobBless" is that it is one of the strangest bits 
of sample code ever to be hosted by Apple, in that it builds and runs but doesn't 
actually *do* anything.

I recommend that OP get the "SMJobBlessXPC" sample code, which builds upon 
"SMJobBless", and actually does something provable, and gives him avenues to debug.

About the code signing, yes-- it is persnickety and finicky… but that's 
code signing.  Don't change anything in the sample code until you have it 
working, then change only the name of your host app, confirm, then change only 
the value of your code sign, confirm, etc

You're correct. I have some code which is adapted from EBAS, so the 
comments misled me, as it's a couple of years since I got all that stuff 
going.


Sorry for the confusion.

John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics, Ukarumpa, Eastern Highlands Province, 
Papua New Guinea

Mussau-Emira language, Mussau Island, New Ireland Province, Papua New Guinea
___

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: 32-bit / 64-bit roadmap

2016-01-21 Thread John McCall
> On Jan 21, 2016, at 1:57 PM, SevenBits  wrote:
>> On Jan 21, 2016, at 1:32 PM, Fritz Anderson  wrote:
>> 
>> On 21 Jan 2016, at 10:45 AM, Aandi Inston  wrote:
>>> 
>>> So far as I can see, all recent Mac OS systems are 64-bit on 64-bit
>>> hardware and can run an app shipped in 64-bit only. And 32-bit continues to
>>> run fine.
>>> 
>>> But what about the future? Perhaps we can only speculate about whether
>>> 32-bit apps will be deprecated, but maybe Apple have started to hint that
>>> 32-bit has a limited lifetime? It's a question of prioritising work on old
>>> apps, and what will happen to our customers with older apps in future.
>>> Let's assume Cocoa has been weeded out of the apps already.
>>> 
>>> Thanks in advance for your speculations (or more solid facts!)
>> 
>> The people with solid facts don’t hang around on mailing lists like this, 
>> and would be fired if they responded. Apple does not comment on its plans. 
>> What we do know is this:
>> 
>> We have more than hints. Apple has steadily increased the incentives for 
>> third-party developers to drop 32-bit products. But it hasn’t even 
>> deprecated it, much less cut it off. Unless I had to accommodate a market 
>> (like education) that hangs onto hardware for a very long time, I’d never 
>> consider anything but 64 bits.
>> 
>> Apple itself has a harder decision, because it doesn’t want to break 
>> developers’ remaining 32-bit products. (Add the “Kind” column to Activity 
>> Monitor to see what I mean.)
>> 
>> All we can know is that deprecation will come no sooner than June (10.12 
>> Tehachapi), withdrawal no sooner than June of 2017 (10.13 San Quentin).
> 
> Unrelated, but… are these the official code names?

Well, not anymore. :)

John.
___

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: LGPL code in the Mac App Store?

2016-01-29 Thread John Daniel
The whole idea behind “open source” vs. “free software” has a long and very 
muddy history. Generally speaking, “open source” is a development methodology 
and “free software” is a political methodology. I don’t think it is correct to 
even use something like “vs.” between them like I did above. 

I think if you are putting software into Apple’s apps stores, you have to focus 
on practical details. One of the things that makes non-GPL licenses attractive 
is just that they are so much simpler to understand for people who don’t have 
their own legal staff. Few companies have a legal staff like Apple, and even 
Apple avoids GPL. 

I’m not making a value judgement here. Sometimes the GPL is the right choice. 
But how much effort are you going to put into this app hoping that you’re 
right? What if the author of that library thinks that you have violated the 
license and contacts Apple complaining about your license violation? 

Is there another library you can use instead? Can you deploy the GPL code on a 
server where it would be more legal? Then charge people money for a 
subscription access to this functionality.

> On Jan 29, 2016, at 3:00 PM, cocoa-dev-requ...@lists.apple.com 
> <mailto:cocoa-dev-requ...@lists.apple.com> wrote:
> 
> I think that this is a slightly uncharitable view of OSS devs, but not 
> terribly inaccurate.

John Daniel
Etresoft, Inc.

___

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

NSDateFormatter behavior

2016-02-13 Thread John MacMullin
I have a date formatter applied to a formcell: 'MM/dd/’.

Upon entering the year, the field ‘completes' so that when I enter 01/01/2 it 
converts it to 01/01/0002, inserting the zeros.

How do I stop the 'completion' behavior?

I have looked at:[aTextView setAutomaticQuoteSubstitutionEnabled:NO]; and 
[aTextView setAutomaticTextReplacementEnabled:NO];

but can’t figure out how to get the textfield textview from the NSFormCell.  
This of course assumes that this is the correct direction to take.

Any ideas?

Best regards,

John
___

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

[OT] Forums for Web Development?

2016-02-15 Thread John Bartleson
After getting many great tips from this list over the years, I find myself 
needing to switch gears and do some web development. I'm starting on a 
server-based app that will be the front end to a SQL database that may grow to 
be very large. Although it's easy to find info on the basic technologies to be 
used in such an app (PHP, Javascript, HTML, SQL, AJAX, etc.), there seems to be 
little written about how to front-end a large multi-server database.

So I'm looking for a forum where I can ask noob questions about large website 
development. Apple (understandably) doesn't appear to have a list for this. Can 
anybody here point to info sources such as forums, books, websites, etc.? TIA
___

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

cycle windows

2016-02-26 Thread John Weeks
Is there a way to query the keyboard equivalent for Cycle Windows? Or maybe a 
notification of some sort that Cycle Windows has been triggered?

Thanks!

-John Weeks
WaveMetrics, inc.


___

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: Returning a string value from a c function to a Objective-C class method. Is there an approved approach?

2016-03-04 Thread John McCall

> On Mar 4, 2016, at 4:03 PM, Greg Parker  wrote:
> 
> 
>> On Mar 4, 2016, at 2:24 PM, Jonathan Mitchell  wrote:
>> 
>> Hi Alex
>> 
>> Not sure if this will help at all as I am not 100% sure what you are doing.
>> In my case, using Mono, I needed to track events being raised in the Mono C 
>> runtime back into Obj-C space.
>> You need some method of defining a call back function in the target C Api - 
>> without that thinks would look rather bleak.
>> 
>> Basically the C Mono runtime is configured to a call static C function in an 
>> Obj C .m file in response to a C# managed event firing.
>> The static then calls a static method on an Obj-C class.
>> This Obj-C static uses collections to track registered events and invokes 
>> performSelector: on a registered Obj-C target.
>> See here:
>> https://github.com/ThesaurusSoftware/Dubrovnik/blob/master/Framework/XCode/Representations/DBManagedEvent.m
>> 
>> One of the arguments based in as part of the event callback is a pointer 
>> that is used as a a key to retrieve the target NSObject.
>> This is complicated by the fact that the incoming pointer represents a 
>> moveable memory location so there is some extra indirection too.
>> https://github.com/ThesaurusSoftware/Dubrovnik/blob/master/Framework/XCode/Representations/DBPrimaryInstanceCache.m
>> 
>> This can get a bit complex but its all doable.
> 
> Block objects can help. clang supports block objects in plain C code 
> (-fblocks, I think).

They're just enabled by default on our platform in all language modes.

John.

> Your Objective-C code can create a block object that performs the callback 
> and pass it to the C code to store and call. The block object would capture 
> the target NSObject so you don't need the dictionary of callback targets.
> 
> 
> -- 
> Greg Parker gpar...@apple.com Runtime Wrangler
> 
> 
> 
> ___
> 
> 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/rjmccall%40apple.com
> 
> This email sent to rjmcc...@apple.com


___

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

Reading XML 1.1

2016-03-14 Thread John Brownie
Is it possible to read an XML 1.1 file using NSXMLDocument? The crucial 
thing for my purposes is that the character set allowed in XML 1.1 is 
larger. XML 1.0 defines characters as:


Char   ::=   #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | 
[#x1-#x10]


XML 1.1 defines:

#2   Char  ::=   [#x1-#xD7FF] | [#xE000-#xFFFD] | 
[#x1-#x10]/* any Unicode character, excluding the surrogate 
blocks, FFFE, and . */
#2a   RestrictedChar  ::=   [#x1-#x8] | [#xB-#xC] | 
[#xE-#x1F] | [#x7F-#x84] | [#x86-#x9F]


I need to be able to handle the RestrictedChar characters, but 
NSXMLDocument apparently only handles the XML 1.0 character set.


Is there a way to make NSXMLDocument handle the fuller character set? If 
not, is there an alternative that will enable me to parse an XML 1.1 
file with a minimum of effort?


Thanks,
John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics, Ukarumpa, Eastern Highlands Province, 
Papua New Guinea

Mussau-Emira language, Mussau Island, New Ireland Province, Papua New Guinea
___

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: Reading XML 1.1

2016-03-19 Thread John Brownie

On 14/03/2016 19:14, John Brownie wrote:
Is it possible to read an XML 1.1 file using NSXMLDocument? The 
crucial thing for my purposes is that the character set allowed in XML 
1.1 is larger. XML 1.0 defines characters as:


Char   ::=   #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] 
| [#x1-#x10]


XML 1.1 defines:

#2   Char  ::=   [#x1-#xD7FF] | [#xE000-#xFFFD] | 
[#x1-#x10]/* any Unicode character, excluding the 
surrogate blocks, FFFE, and . */
#2a   RestrictedChar  ::=   [#x1-#x8] | [#xB-#xC] | 
[#xE-#x1F] | [#x7F-#x84] | [#x86-#x9F]


I need to be able to handle the RestrictedChar characters, but 
NSXMLDocument apparently only handles the XML 1.0 character set.


Is there a way to make NSXMLDocument handle the fuller character set? 
If not, is there an alternative that will enable me to parse an XML 
1.1 file with a minimum of effort?


No actual answers, but the best I've found is to use the expat XML 
parser with the expatobjc wrapper, and go in and change the ASCII tables 
to handle the extra characters (change from BT_NONXML to BT_OTHER). Of 
course, it is not as simple as NSXMLDocument in that I have to do the 
parsing myself rather than having it give me a nice tree structure which 
I can walk to create my internal data structure. It would be even nicer 
to have it in Swift, but I guess I can live with ObjC for now.


John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics, Ukarumpa, Eastern Highlands Province, 
Papua New Guinea

Mussau-Emira language, Mussau Island, New Ireland Province, Papua New Guinea
___

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

Creating NSXMLDocument programmatically

2016-03-22 Thread John Brownie
I'm building an XML tree from an XML file which is XML 1.1, so has 
character references that NSXMLDocument cannot handle natively. So, I'm 
working with a modified version of the Expat parser and building the 
tree as I go.


The problem: How do I associate a DTD with the document? setDTD: became 
unavailable in 10.10, but there appears to be no replacement. I'm still 
running Xcode 7.0.1, so maybe there's something newer that I can't see, 
but a Google search doesn't turn it up. Using addChild: raises an 
exception, so I'm wondering if there is any way to do this now.


Thanks for any pointers.

John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics, Ukarumpa, Eastern Highlands Province, 
Papua New Guinea

Mussau-Emira language, Mussau Island, New Ireland Province, Papua New Guinea
___

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: Creating NSXMLDocument programmatically

2016-03-22 Thread John Brownie

___

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 John Pannell
I've seen quite a bit on my newsfeed regarding this...

http://mjtsai.com/blog/2016/03/31/gatekeeper-bug-in-mac-os-x-10-11-4/
https://www.noodlesoft.com/blog/2016/04/05/hazel-3-3-8-getting-past-the-gates/
https://forums.developer.apple.com/message/81349#81349

Haven't seen any workarounds yet - hope this helps!

John

On Thu, Apr 7, 2016, at 08:13 AM, Trygve Inda wrote:
> 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/johnp%2Blists%40peach.io
> 
> This email sent to johnp+li...@peach.io
___

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: BOOL parameter passed as nil object

2016-04-19 Thread John McCall
> On Apr 19, 2016, at 1:20 PM, Alex Zavatone  wrote:
> On Apr 19, 2016, at 3:23 PM, Greg Parker wrote:
> 
>> 
>>> On Apr 19, 2016, at 12:07 PM, Jens Alfke  wrote:
>>> 
>>>> On Apr 19, 2016, at 10:22 AM, Alex Zavatone  wrote:
>>>> 
>>>> I believe that a BOOL can only be YES or NO.  A nil value on a BOOL would 
>>>> be NO if I am correct. 
>>> 
>>> At the language level, yes.
>> 
>> Not even there. On some platforms BOOL is defined as signed char. It may 
>> have any of 254 values other than YES or NO.
> 
> IIRC from when I was playing with the runtime, Isn't our friend the BOOL 
> backed by a char in Obj-C?  

Greg answered this already.  Sometimes it's signed char, sometimes it's C99 
_Bool / C++ bool.  It's platform-dependent.

> Considering its use at the language level, would values of nil and 0 result 
> as NO and every other value of 1 or > == YES?

Passing a value of pointer type and then receiving it as a value of type BOOL 
is not guaranteed to work in the calling convention, full stop.  It can 
arbitrarily misbehave.

On current Apple platforms, they will both generally be passed in a roughly 
equivalent way on the "physical" level: i.e. in a pointer-sized register or 
chunk of stack space.  So on the most primitive level, it will "work" in the 
sense that it will not e.g. leave the stack misaligned or cause later arguments 
to be misinterpreted.

However, a pointer value will generally not satisfy the requirements of a BOOL 
argument.  For example, on some platforms, when a 'signed char' argument is 
passed in a register, it must first be sign-extended:, and the callee may 
assume that the high bits will be all-zeroes or all-ones.  Similarly, the 
callee may assume that a _Bool argument will be either 0 or 1; whether that's a 
guarantee for the entire register or just the low 8 bits is also 
target-dependent.  So nil may satisfy the representation rules for NO, but a 
non-nil pointer will usually violate the representation rules and may result in 
unreliable behavior in practice.

Plus, of course, even if it all works out on these primitive levels, it's still 
actually undefined behavior in the end, and so the compiler reserves the right 
to find a way to miscompile your program.

We strongly encourage you not to worry about any of this and just always call 
methods using the right method signature.

John.
___

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: Converting to ARC and blocks

2016-05-02 Thread John McCall
> On May 2, 2016, at 10:38 AM, Steve Mills  wrote:
> I'm working on a project that's had to support older hardware/software until 
> now, so we can *finally* convert to ARC. Since it's been almost a year since 
> I've worked on anything that used ARC, I'm a little rusty on some of the 
> stranger stuff, like __unsafe_retained. Here's a pared down hunk before 
> converting to ARC:
> 
> NSXMLElement* root = [NSXMLNode elementWithName:@"manifest" children:nil 
> attributesWithDict:@{@"thing":@"stuff"}];
> 
> __block NSXMLElement* rezes = [NSXMLNode elementWithName:@"resources"];
> __block NSXMLElement* rez;
> 
> [root addChild:rezes];
> 
> [indices enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL* stop) {
>rez = [NSXMLNode elementWithName:@"resource" children:nil 
> attributesWithDict:@{@"identifier":item}];
>[rezes addChild:rez];
>[self _addQTIManifestResources:images addResourcesToNode:rezes];
> }];
> 
> After using Edit->Convert->To Objective-C ARC, the 2nd line was changed to:
> 
> __unsafe_unretained NSXMLElement* rezes = [NSXMLNode 
> elementWithName:@"resources"];
> 
> I've looked around, but can't find anything that explains why 
> __unsafe_retained is needed AND why __block is NOT needed.

You don't have to declare something with __block just to use it in a block.  
__block specifically means that the variable will be captured *by reference* in 
the block, meaning that changes to the variable within the block are visible in 
the original scope and vice-versa.  Without this, the block literal will 
capture the current value of the variable, and you will not be able to assign 
to it within the block.

When blocks capture a value of ObjC pointer type like that, they retain it.  
That's not always desired, either for efficiency reasons or because it 
introduces retain cycles, and so __block is sometimes used in non-ARC code as a 
(very inefficient) way to prevent that retain.  That doesn't work in ARC, 
because assigning to a __strong __block variable retains the new value, just 
like assigning to any other __strong variable.  So the migrator tries to 
recognize __block variables that are being used that way (i.e. __block 
variables that are never modified) and instead declare them as 
__unsafe_unretained.

John.
___

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: Converting to ARC and blocks

2016-05-02 Thread John McCall
> On May 2, 2016, at 11:30 AM, Steve Mills  wrote:
> 
> On May 02, 2016, at 12:58 PM, John McCall  wrote:
> 
> > You don't have to declare something with __block just to use it in a block. 
> > __block specifically means that the variable will be captured *by 
> > reference* in the block, meaning that changes to the variable within the 
> > block are visible in the original scope and vice-versa. Without this, the 
> > block literal will capture the current value of the variable, and you will 
> > not be able to assign to it within the block.
> 
> Ah yes, good point. My __block decoration on rezes might've been done in an 
> earlier iteration of the code, where it really *was* allocated and assigned 
> inside the block.
>  
> > When blocks capture a value of ObjC pointer type like that, they retain it. 
> > That's not always desired, either for efficiency reasons or because it 
> > introduces retain cycles, and so __block is sometimes used in non-ARC code 
> > as a (very inefficient) way to prevent that retain. That doesn't work in 
> > ARC, because assigning to a __strong __block variable retains the new 
> > value, just like assigning to any other __strong variable. So the migrator 
> > tries to recognize __block variables that are being used that way (i.e. 
> > __block variables that are never modified) and instead declare them as 
> > __unsafe_unretained.
> 
> So is the compiler/migrator recognizing here that rezes get added to the root 
> object, then later used in various blocks (there are more than one, but I 
> didn't show them) before finally going out of scope, so it's just being more 
> efficient, rather than just letting its retain count get incremented when 
> it's added to root, then decremented when rezes goes out of scope?

No.  It's just recognizing that putting __block on rezes is otherwise pointless 
because you never assign to it, so it guesses that you might be trying to 
suppress a retain.

Now, maybe that's giving the programmer too much credit. :)  But I think it's 
more reasonable to add __unsafe_unretained than to silently do nothing at the 
risk of introducing a retain cycle — for one, it's preserving the behavior of 
your code, and for another, it's much easier for programmers to statically see 
the explicit __unsafe_unretained and try to figure out if it's reasonable than 
for them to dynamically track down yet another retain cycle.  Migrating to ARC 
is definitely *not* fire-and-forget!  You really do need to look over the 
results and see whether they make sense.

John.
___

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: Receiver type for instance message is a forward declaration

2016-05-06 Thread John McCall
> On May 6, 2016, at 1:32 PM, Carl Hoefs  wrote:
> I'm building for iOS 9.3, and am using NSOperationQueue throughout. Once in a 
> while, NSOperationQueue -addOperation: throws an exception. I guess this is a 
> well-known bug going all the way back to 2008. I found Mike Ash's writeup on 
> the issue, and have downloaded his replacement class, RAOperationQueue. 
> However, it was written long ago for GC not ARC. I have one remaining problem 
> in converting the code.
> 
> - (BOOL)_runOperationFromList: (RAAtomicListRef *)listPtr sourceList: 
> (RAAtomicListRef *)sourceListPtr
> {
>   RAOperation *op = [self _popOperation: listPtr];
>   if( !op )
>   {
>   *listPtr = RAAtomicListSteal( sourceListPtr );
>   // source lists are in LIFO order, but we want to execute 
> operations in the order they were enqueued
>   // so we reverse the list before we do anything with it
>   RAAtomicListReverse( listPtr );
>   op = [self _popOperation: listPtr];
>   }
>   
>   if( op )
>   [op run];  <-- ERROR HERE
>   
>   return op != nil;
> }
> 
> The error I'm getting is: Receiver type 'RAOperation' for instance message is 
> a forward declaration.
> 
> What does this error mean, and how can I fix it?

It means you haven't #included the header with the @interface declaration for 
RAOperation.

John.
___

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: How to keep things alive in Arc?

2016-05-10 Thread John McCall
> On May 9, 2016, at 6:38 AM, gerti-cocoa...@bitart.com wrote:
> This was recommended to me by folks "in the know":
> 
>   Thing *aThing = [ Thing new ];
>   
>   ...
>   
>   (void)aThing;

This is not guaranteed to keep aThing alive for its full scope.  You should use 
the precise-lifetime attribute.

John.
___

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: Problem about math library and the standard namespace of Apple Clang

2016-05-12 Thread John McCall
> On May 12, 2016, at 7:00 AM, 军其 胡  wrote:
> Hi, all.
> 
> My question is about the convention of the standard namespace in C++. 
> firstly, let's read the following classic example in C/C++:
> 
> ,-
> | #include 
> | #include 
> |
> | double fabs(double a)
> | {
> | return -1.0*a;
> | }
> |
> | int main()
> | {
> | double b=fabs(3.0);
> | double c=std::fabs(3.0);
> | printf("%f, %f\n",b,c);
> | }
> `-
> 
> The Xcode (or Apple Clang) gives the results with both 3.00.  I have 
> tried to compile the same code by GCC on Fedora 22 and obtain the opposite 
> results with both -3.00. It's ridiculous since fabs and std::fabs are 
> lying in different namespaces.

 is allowed to declare entities in both namespace std and the global 
namespace, and they are permitted to be the same entity.  As far as the 
compiler is concerned, your declaration of fabs is an attempt to implement the 
C standard library's fabs function, which the C++'s library is just an alias 
of.  That is why both of these calls call your function.

You should not declare functions in the global namespace with the same name as 
C library functions unless you really do mean to override them.

John.

> I also compile the following C/C++ codes:
> 
> ,---
> | #include 
> | #include 
> |
> | int abs(int a)
> | {
> | return -1*a;
> | }
> |
> | int main()
> | {
> | int b=abs(3);
> | int c=std::abs(3);
> | printf("%b, %c\n", b, c);
> | }
> `---
> 
> in Xcode. Now, it gives me the error about ambiguous calling to std::abs 
> function while GCC gives me the right answer. After browsing the hierarchy of 
> C/C++ headers
> 
> ,--
> | $ cd /Applications/Xcode.app/Contents
> | $ find . -iname 'cmath'
> | 
> ./Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/cmath
> | 
> ./Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/tr1/cmath
> | 
> ./Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/cmath
> | 
> ./Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/tr1/cmath
> | 
> ./Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1/cmath
> | 
> ./Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1/tr1/cmath
> | ./Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath
> `--
> 
> I found out that Apple Clang doesn't offer the newest math library. Anyone 
> knows what happened between math library and standard namespace?
> 
> 
> Best wishes,
> 
> Jun-Qi Hu
> ___
> 
> 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/rjmccall%40apple.com
> 
> This email sent to rjmcc...@apple.com


___

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 initialKey & initialValue be set via bindings?

2016-06-15 Thread John Chacho
(warning:I may not be asking the right question)

Here's what I have:

A simple app with a NSTableview, 2 buttons, 2 fields, a controller, and a
dictionary controller.

The dictionary Controller content is bound to the NSDictionary instance
property in the App Controller. The app Controller just inits the
NSDictionary from a pfile and saves to the pfile on exit. No other methods
in there.
(IB > Dictionary Controller > Bindings Inspector > Controller Content >
Bind to: "App Controller" Model Key Path:myDict)

Tableview Columns are bound to the "key" and "value" objects of the
arrangedObjects in the Dictionary Controller
(IB > Tableview > Column > Bindings Inspector > Bind to: "Dictionary
Controller" Controller Key:arrangedObjects) Model Key Path: key)

I start up the app and the table is populated. An "Add" button bound to the
add method of the dictionary controller adds values "key" and "value" then
"key1" and "value" to the table and so on.

A "Remove" button bound to the remove method of the dictionary controller
removes records from the table.

Here's what I want to do:

I want to have control over the new values entered into the dictionary and
hence the table. Instead of "key" and "value" being enter as new records
into the table, I want the new record to be based on the values in the two
fields on the interface.

It seemed like the solution was to bind the "Initial Key" and "Initial
Value" of the Dictionary Controller to the stringValue of the fields.
(IB > Dictionary Controller > Bindings Inspector > Parameters > Inital Key
> Bind to: app Controller Model Key Path: self.kTextfield.stringValue)

But despite the Model Key Path re-assuredly auto-completing to:
"self.kTextfield.stringValue", it does not work. The values entered in the
table are blank.

Is there a way to bind initial key and initial value to textfield values
using the Bindings Inspector?

If not, how can I add an arbitrary new record into the dictionary?

Regards,
John
___

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: Can initialKey & initialValue be set via bindings?

2016-06-16 Thread John Chacho
I should have been more clear, the new entries are simple key-value pairs
where the values are simple strings.

Your reply helped me understand some of my confusion, but not before I had
tried a few crazy ideas and received embarrassing exceptions like:

initValue[6961:329407] [
addObserver:
forKeyPath:@""
options:0 context:0x600e4500] was sent to an object that is not
KVC-compliant for the "" property.

and

-[NSTextField copyWithZone:]: unrecognized selector sent to instance

After revisiting the KVC and KVO documentation, working on something else
and forcing myself to not think about the seemingly trivial problem...
What I hope is a safe, simple and non-memory-leaky solution popped into
focus:

1. Declare and synthesize two properties to hold a key NSString and a value
NSString in the controller.
2. Bind the NSTextFields to the properties and check "Continuously Updates
Values"
3. Bind the NSDictionaryControl "Initial Key" and "Initial Value" to the
properties.

PS: Another factor that may have muddied the water for me was not
Command-S'ing to save my hasty, fool-hearty and something angry XIB and
other file updates before compiling and running.



On Thu, Jun 16, 2016 at 2:40 PM, Quincey Morris <
quinceymor...@rivergatesoftware.com> wrote:

> On Jun 15, 2016, at 21:23 , John Chacho  wrote:
>
>
> If not, how can I add an arbitrary new record into the dictionary?
>
>
> If I understand correctly, you have to go the long way round for this
> scenario (which is not specific to NSDictionaryController). Instead of
> connecting your Add button to the standard “add:” action of the
> NS…Controller, you must instead create a custom action method, e.g.
> ‘addEntry:’. In this method, you’ll need to get hold of the current
> selection (if that’s where the "based on” values come from), verify that
> it’s suitable for creating a new entry, create the entry, then add the new
> entry to your data model dictionary KVO compliantly — or use the
> NS…Controller’s ‘addObject:’ method, which causes a KVO compliant update.
> (Both ways are equally easy for an underlying NSDictionary, since it
> provides KVO compliance for free, but it can be slightly harder for other
> underlying collection types.)
>
> In effect, the above is exactly what the ‘add:’ action method does, except
> that it can’t customize the data model object it creates to add.
>
>
___

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

Normalising file names on macOS

2016-09-22 Thread John Brownie
I find that I am in need of dealing with versions of strings that may be 
turned into file names, and thus I need to be comparing normalised 
forms. However, according to 
https://developer.apple.com/library/content/qa/qa1173/_index.html, "For 
example, HFS Plus (Mac OS Extended) uses a variant of Normal Form D in 
which U+2000 through U+2FFF, U+F900 through U+FAFF, and U+2F800 through 
U+2FAFF are not decomposed (this avoids problems with round trip 
conversions from old Mac text encodings)."


Is there a way to get at this variant? [NSString 
decomposedStringWithCanonicalMapping] returns "A string made by 
normalizing the string’s contents using the Unicode Normalization Form 
D." That seems not to give what I need, but I haven't seen a better 
option. Is there such a method?


John
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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: Normalising file names on macOS

2016-09-22 Thread John Brownie



Alastair Houghton <mailto:alast...@alastairs-place.net>
22 September 2016 at 14:31

This is rather a hairy problem, actually. You don’t know that the 
filesystem is actually HFS+. The filename in question could refer to a 
file on an NTFS volume, or (in future) an APFS volume. It could also 
be a network filesystem, which could be mounted on a system running a 
completely different operating system with unknown character encoding 
behaviour; typically UNIX behaviour, for instance, is to completely 
ignore the filename encoding problem and treat filenames as a string 
of bytes (thus you are free to interpret them as UTF-8 if you so wish, 
but the filesystem will regard U+00E9 as different from U+0065 U+0301, 
even though the two names will display the same on screen).

True, it could be another file system. Another wrinkle!
Additionally, the version specified in HFS+ was based on a particular 
version of the Unicode standard (I forget which), but importantly 
*not* the current version, which is what the NSString APIs will use.


Perhaps we should start by understanding the context of your question. 
Is there a specific reason you want to match the filesystem behaviour 
precisely?
OK, the situation is that the user provides a name, which comes in 
through a standard text field in a dialog. That name is used as a key 
for a dictionary which gives a collection of information about that 
item. It is also used to create a file, hence it becomes a file name 
(with an appropriate extension). A complication is that the document is 
stored as a bundle, and the name is used as a file name for a file in 
the Resources directory and referenced in the info.plist file.


When reading the document from disk, I need to match up the file name 
with the appropriate entry in the info.plist. Currently that works as 
long as I don't hit the normalisation issue. If I get a precomposed 
character given to me, then the file name becomes the decomposed 
version, and I've lost the mapping.


The most obvious solution is to create the file and then see what I get 
back, and use that for the key. However, saving the whole bundle can be 
an expensive operation, so I wouldn't want to do it lightly. Then I 
might get the issue of different file systems, though it's less likely 
to be an issue, or at least it's less likely that a user would save it 
to two different file systems.


I could perhaps create a scratch file with the given name, but that runs 
into the possibility of different file systems. Still, if there's no 
better option, I can work with that.


Oh, and if it makes any difference, I'm supporting back to OS X 10.8 
currently.


John
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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: Normalising file names on macOS

2016-09-22 Thread John Brownie
Thanks, that sounds like a couple of good options. I'll try some options 
with the second one, and fall back on the first if necessary.


Alastair Houghton wrote:

My recommendation would be as follows:

1. If possible, don’t base the filename on the user’s input.  Instead, generate 
your own filename (one option might be to use a UUID) and then store a 
dictionary mapping the user’s input to the filename somewhere in your bundle.  
This avoids any problems with filename encoding completely.  You will still 
have to worry about normalising the user’s input, but that’s then just a matter 
of choosing a normalisation.

2. If you must base the filename on user input, do so by stripping out 
non-ASCII characters and replacing them with e.g. ‘_’s.  You’ll also need to 
make sure that the result is unique, otherwise a user might specify two names 
that both map to the same ASCIIfied name.  You’ll still want to store the 
dictionary mapping the user’s input.

The benefit of the second approach is that your bundle is more easily 
understood by a human being.  The downside is that it’s more complicated to 
implement.

Both will work, whatever the filesystem is, as they don’t rely on filesystem 
encoding behaviour.

(You might also then ponder whether you want things to be case-sensitive or 
not; the above will be.  Making it not case-sensitive is a little tricky in 
that just converting to upper or lower case doesn’t*quite*  work; the correct 
approach would be to use CFStringFold() to case-fold the string,*after*  
normalising, before using it as a dictionary key.)

John
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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

Traceback from [SFLList removeItem:]

2016-10-26 Thread John Brownie
Recently, I think since I updated to Sierra and Xcode 8, I get 
tracebacks like the following in the Xcode console on application close:


2016-10-26 12:06:25.021123 MyApp[7966:1254722] Item: filename.bundle 
[95A054A5-60CF-4BB7-B898-95C221DA0790] - 
URL:file:///path/to/filename.bundle/ 1   
SharedFileList  0x7fffa6958549 -[SFLList 
removeItem:] + 57
2   SharedFileList  0x7fffa696c089 
LSSharedFileListItemRemove + 176
3   AppKit  0x7fffa36848ea 
-[NSDocumentController _refreshRecentDocumentURL:newURL:forDocument:] + 308
4   AppKit  0x7fffa3bc4537 
__85-[NSDocument(NSDocumentSaving) 
_saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke.999 
+ 112
5   AppKit  0x7fffa3bc4ee7 
__85-[NSDocument(NSDocumentSaving) 
_saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke_4.1040 
+ 31
6   libdispatch.dylib   0x000100e3074d 
_dispatch_call_block_and_release + 12
7   libdispatch.dylib   0x000100e26fcc 
_dispatch_client_callout + 8
8   libdispatch.dylib   0x000100e37a2f 
_dispatch_queue_override_invoke + 1360
9   libdispatch.dylib   0x000100e29247 
_dispatch_root_queue_drain + 671
10  libdispatch.dylib   0x000100e28f58 
_dispatch_worker_thread3 + 114
11  libsystem_pthread.dylib 0x000100e9e8c2 
_pthread_wqthread + 1299
12  libsystem_pthread.dylib 0x000100e9e39d 
start_wqthread + 13


I assume that I can safely ignore these as someone leaving debug 
printing on, since all continues to work. Or do I need to worry?

--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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: Traceback from [SFLList removeItem:]

2016-10-26 Thread John Brownie

Quincey Morris wrote:
I would worry just a little bit. The messages you showed are not debug 
printing, but a backtrace, which *may* indicate that an exception was 
thrown.
No exceptions as far as I can see. I have an exception breakpoint for 
all exceptions, and it isn't triggered.

Submit a bug report, and see what comes back.

I guess that's the next step.

New Guinea to Finland?? Are you insane??? ;)
Well, when you live in the tropics, you do look forward to cool weather! 
But seriously, it's necessary to see family and supporters from time to 
time. Having grown up in Australia, snow is still pretty exciting, 
though less so for my wife, who is the Finn.

--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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: function signature specialization crashlog

2016-10-31 Thread John McCall
> On Oct 31, 2016, at 6:12 AM, Torsten Curdt  wrote:
> 
> I have a real hard time understanding this iOS/Swift3 crashlog.

This is an odd list to be posting this to.  Crash logs are there for the 
developers
of the crashing software.  If you're interested in helping fix the compiler, 
that's great,
but you should be bringing this up on swift-dev.  If you're just trying to 
figure out how
to get the Swift compiler to stop crashing on your code, the crash logs probably
aren't going to help that much.

> For one the closure #s do not help that very much (I just assume they numbered
> from the beginning of the file?)

They should be numbered from the beginning of the enclosing entity: in this
case, the enclosing method.

> and the closure line numbers are all 0.

That's probably because it's implicitly-generated code.

> Any ideas what could be going on?

I'm afraid not.  Please file a radar.

John.

> 
> cheers,
> Torsten
> 
> 0   Foo  0x0001000b8e10
> 
> function signature specialization  Owned To Guaranteed> of Foo.StoresViewController.(viewDidLoad () ->
> ()).(closure #20) (StoresViewController.swift:0)
> 
> 1   Foo  0x0001000b8fa4
> 
> function signature specialization  Owned To Guaranteed, Arg[2] = Owned To Guaranteed> of function signature
> specialization  Foo.StoresViewController.(viewDidLoad () -> ()).(closure #20)]> of
> Foo.StoresViewController.(viewDidLoad () -> ()).(closure #21)
> (StoresViewController.swift:0)
> 
> 2   Foo  0x0001000b2814
> function signature specialization  Foo.StoresViewController.(viewDidLoad () -> ()).(closure #20)]> of
> Foo.StoresViewController.(viewDidLoad () -> ()).(closure #21)
> (StoresViewController.swift:0)
> 
> 3   Foo  0x0001000bb11c
> 
> partial apply forwarder for reabstraction thunk helper from @callee_owned
> (@owned [Foo.Store], @owned __ObjC.CLLocation?, @owned __ObjC.CLLocation?,
> @unowned Swift.Bool) -> (@owned [Foo.Store], @error @owned Swift.Error) to
> @callee_owned (@in [Foo.Store], @in __ObjC.CLLocation?, @in
> __ObjC.CLLocation?, @in Swift.Bool) -> (@out [Foo.Store], @error @owned
> Swift.Error) (StoresViewController.swift:0)
> 
> ...
> ___
> 
> 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/rjmccall%40apple.com
> 
> This email sent to rjmcc...@apple.com


___

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: function signature specialization crashlog

2016-10-31 Thread John McCall
> On Oct 31, 2016, at 3:49 PM, Torsten Curdt  wrote:
> 
> > I have a real hard time understanding this iOS/Swift3 crashlog.
> 
> This is an odd list to be posting this to.  Crash logs are there for the 
> developers
> of the crashing software.  If you're interested in helping fix the compiler, 
> that's great,
> but you should be bringing this up on swift-dev.  If you're just trying to 
> figure out how
> to get the Swift compiler to stop crashing on your code, the crash logs 
> probably
> aren't going to help that much.
> 
> Hey John,
> 
> maybe this was misleading. It's from a crashlog from an iOS app - not the 
> compiler. I only tried to point out it was written in Swift3. But you might 
> be right and it's more a Swift question and therefor the wrong list.

I see.  If it's a crash in running code, that's different.

> My app crashed and I am trying to figure out what that crashlog means.
> Given that I have no line numbers it's a bit of a guessing game.
> And the error itself does not ring a bell either yet.

From the information there, I would guess that maybe the closure has been 
released or corrupted.

> Maybe I should also try on the Swift IRC channel.
> 
> Thanks for that input.
> 
> 
> > For one the closure #s do not help that very much (I just assume they 
> > numbered
> > from the beginning of the file?)
> 
> They should be numbered from the beginning of the enclosing entity: in this
> case, the enclosing method.
> 
> Ah. OK. Wish I could have Xcode show me those numbers.

If it helps, it looks like:

 - you're calling a function with the signature ([Foo.Store], CLLocation?, 
CLLocation?, Bool) throws -> [Foo.Store]
 - that function is calling another closure
 - that closure is crashing

> > and the closure line numbers are all 0.
> 
> That's probably because it's implicitly-generated code.
> 
> Hm. What is implicit about that closure code?
> I wrote it and hence it should have line numbers.

The code is at least wrapped with some implicit code, and it may be that code 
which is crashing.

John.
___

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: didPrint selector not called

2016-12-16 Thread John McCall
> On Dec 16, 2016, at 8:45 AM, Jeremy Hughes  
> wrote:
> Hi,
> 
> I’m overriding printDocumentWithSettings in order to get a notification for 
> when printing has finished, but the didPrint selector is never called.
> 
> This is the code:
> 
> class func document(document: NSDocument, didPrint: Bool, contextInfo: 
> UnsafeMutablePointer)
> {
>   print("document was printed”)
> }
> 
> override func printDocumentWithSettings(printSettings: [String : AnyObject], 
> showPrintPanel: Bool, delegate: AnyObject?, didPrintSelector: Selector, 
> contextInfo: UnsafeMutablePointer)
> {
>   let didPrint = #selector(Document.document(_:didPrint:contextInfo:))
>   
>   super.printDocumentWithSettings(printSettings, showPrintPanel: 
> showPrintPanel, delegate: delegate, didPrintSelector: didPrint, contextInfo: 
> contextInfo)
> }
> 
> Does anyone know why this doesn’t work?

The selector is invoked on the delegate object that you pass.  Since the 
selector is for a class method on Document, the delegate needs to be the class 
object for Document, which I assume it probably isn't.

It does seem kindof weird to be ignoring the delegate/selector pair that was 
passed in, though.

John.
___

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: didPrint selector not called

2016-12-16 Thread John McCall
> On Dec 16, 2016, at 11:24 AM, Jeremy Hughes  
> wrote:
> Thanks for the link.
> 
> I’ve looked at it, and I don’t think it applies in this case, because I’m not 
> actually overriding the document(_:didPrint:contextInfo:) method, just 
> providing it as a callback. There isn’t an override keyword before the 
> method, and there isn’t a superclass method that I can call through to. I 
> suppose it would apply if I had a subclass (of my document class) that needed 
> to override the callback. Does that seem right to you?

You're overriding printDocumentWithSettings to ignore the passed-in delegate 
and selector.  Unless you're certain that the passed-in delegate and selector 
are never useful, you're probably breaking something.

John.

> 
> Jeremy
> 
> --
> 
>> On 16 Dec 2016, at 18:26, Quincey Morris 
>>  wrote:
>> 
>> On Dec 16, 2016, at 08:45 , Jeremy Hughes  
>> wrote:
>>> 
>>> override func printDocumentWithSettings(printSettings: [String : 
>>> AnyObject], showPrintPanel: Bool, delegate: AnyObject?, didPrintSelector: 
>>> Selector, contextInfo: UnsafeMutablePointer)
>>> {
>>> let didPrint = #selector(Document.document(_:didPrint:contextInfo:))
>>> 
>>> super.printDocumentWithSettings(printSettings, showPrintPanel: 
>>> showPrintPanel, delegate: delegate, didPrintSelector: didPrint, 
>>> contextInfo: contextInfo)
>>> }
>> 
>> Apart from the bug John described, where the selector is incorrectly for a 
>> class method…
>> 
>> It’s not absolutely clear, but I think this method comes under the aegis of 
>> “Advice for Overriders of Methods that Follow the 
>> delegate:didSomethingSelector:contextInfo: Pattern” in the OS X release 
>> notes archive:
>> 
>>  
>> developer.apple.com/library/content/releasenotes/AppKit/RN-AppKitOlderNotes/
>> 
>> (Do a text search within the page to find the heading.)
>> 
>> This’ll make your head hurt, but the essence of it is that you’re not 
>> allowed to throw away the selector that’s passed in to the method, and 
>> that’s exactly what you’re doing.
>> 
>> Instead, you need to arrange for your “didPrint” method to invoke the 
>> originally passed-in selector, and depending on the order in which things 
>> need to happen, you make have to construct an invocation. I think (but I’m 
>> not certain) that yours is the “easy” case where you don’t need to construct 
>> the invocation, but you’re going to have to figure that out.
>> 
> 
> 
> ___
> 
> 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/rjmccall%40apple.com
> 
> This email sent to rjmcc...@apple.com


___

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: didPrint selector not called

2016-12-16 Thread John McCall
> On Dec 16, 2016, at 11:33 AM, Jeremy Hughes  
> wrote:
>> On 16 Dec 2016, at 19:29, John McCall  wrote:
>> 
>>> On Dec 16, 2016, at 11:24 AM, Jeremy Hughes  
>>> wrote:
>>> Thanks for the link.
>>> 
>>> I’ve looked at it, and I don’t think it applies in this case, because I’m 
>>> not actually overriding the document(_:didPrint:contextInfo:) method, just 
>>> providing it as a callback. There isn’t an override keyword before the 
>>> method, and there isn’t a superclass method that I can call through to. I 
>>> suppose it would apply if I had a subclass (of my document class) that 
>>> needed to override the callback. Does that seem right to you?
>> 
>> You're overriding printDocumentWithSettings to ignore the passed-in delegate 
>> and selector.  Unless you're certain that the passed-in delegate and 
>> selector are never useful, you're probably breaking something.
>> 
>> John.
> 
> OK - I misunderstood what Quincey was saying.
> 
> The passed-in delegate and selector are nil, but I obviously can’t be sure 
> that they will always be nil.
> 
> All I’m actually trying to do is to clean up some objects that need to exist 
> during the print operation. Is this the best way for me to be doing that?

I'm not an expert in this part of Cocoa.  Are there implicit system *callers* 
of this method, or is it more of a system *utility* that you're expected to 
call from your own code?  If it's the latter, then maybe instead of overriding 
it you should just provide a different method that calls it, doing whatever set 
up you need first and then passing in the appropriate delegate and selector to 
do cleanup.

John.
___

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

Giving names to undo actions

2016-12-21 Thread John Brownie
I have undo working correctly in my macOS app, but I have a question 
about action names.


The documentation tells you to set the name when registering the action 
on the undo stack. The correct name appears in the Undo menu item. The 
trouble is when you have symmetric actions, such as add and delete an 
item. You do an add, which puts the name "add" for the action. Undoing 
it is a remove, which sets the name "remove". Then you have "Redo 
remove" as the menu item, which isn't correct.


It seems that the way to get around this is to set the action name only 
when you are actually doing the original action, and not when doing the 
undo version of it. Is that a correct interpretation? If so, how do you 
implement it? Do you test the NSUndoManager's undoing property and only 
set the name if it is NO?


Any insights welcomed!
John
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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: Giving names to undo actions

2016-12-21 Thread John Brownie
OK, I think you're endorsing what I was planning. I have (among other 
actions) two that are inverses of each other, add and remove. Currently 
the add routine creates an action called Add, and registers the remove 
routine as its undo action. The remove routine creates an action called 
Remove, and register the add routine as its undo action. This leads to 
the redo of add appearing as Undo Remove, and that's my problem.


So there are two approaches I can see. One is to refactor the add and 
remove routines into two levels, one of which does the creation of an 
undo element, and the other actually doing the work. The other is to 
check whether we're undoing and not set the name in that case. At 
present I'm leaning towards the latter.


John

Quincey Morris <mailto:quinceymor...@rivergatesoftware.com>
21 December 2016 at 10:44
On Dec 21, 2016, at 00:06 , John Brownie <mailto:john_brow...@sil.org>> wrote:


No, there are three steps: create, undo, redo. You only set the name 
on the create step. So, after you do the add, the menu reads “Undo 
Add”. After you undo the add, the menu reads “Redo Add”. After you 
redo the add, the menu reads “Undo Add” again.


(IIRC, if you code is structured in such a way that you want to handle 
multiple steps in one place, you can test the “isUndoing” and 
“isRedoing” properties to decide whether to set the name.)




--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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

Is SMJobBless still the correct way to do authorisation?

2017-01-09 Thread John Brownie
I'm working on an app which will be written in Swift, but which needs to 
use some authorisation method to allow creation and deletion of files 
and folders inside the /Library directory. Last time I needed this sort 
of ability (three years ago), I took the SMJobBless sample code, along 
with Even Better Authorization Sample, to create a fairly complex 
system, which I no longer understand at any depth.


Before diving back into all this, am I going in the right direction? Can 
I get away with a simpler system just using SMJobBless as a basis? Is 
there better sample code out there that I can learn from? How will 
mixing Objective-C in the helper application and Swift in the main 
application work in practice?


Any other advice?

Thanks,
John
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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


FSEventStreamCallback in Swift

2017-01-24 Thread John Brownie
My app shows a representation of the contents of various folders, so 
using FSEvents to track modifications from outside the app seemed to be 
the way to go. I am running into difficulty with writing the code with a 
callback, all in Swift. I must be doing something wrong, as I get a 
crash in the callback.


Code in my ViewController class:
let scanTarget = []
let scanCallback: FSEventStreamCallback = { (streamRef: 
ConstFSEventStreamRef, context: UnsafeMutableRawPointer?, count: Int, 
streamPtr: UnsafeMutableRawPointer, flags: 
UnsafePointer?, eventID: 
UnsafePointer?) in

// Convert to appropriate pointer
let theController = context?.bindMemory(to: 
ViewController.self, capacity: 1)

// The following line crashes with a bad address exception
theController?.pointee.
}
var mutableSelf = self
var theContext = FSEventStreamContext(version: 0, info: 
&mutableSelf, retain: nil, release: nil, copyDescription: nil)

let scanInterval: CFTimeInterval = 5.0
eventStream = FSEventStreamCreate(nil, scanCallback, 
&theContext, scanTarget as CFArray, 
FSEventStreamEventId(kFSEventStreamEventIdSinceNow), scanInterval, 
FSEventStreamCreateFlags(kFSEventStreamCreateFlagUseCFTypes))


I may well have the wrong way of handling the conversion through the 
context with all the unsafe pointer types, as I'm still rather new to Swift.

--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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


Debugging a privileged helper

2017-01-26 Thread John Brownie
I have a working app in Objective-C that has a privileged helper. I am 
creating a different app, this time in Swift, and need a privileged 
helper. As far as I can tell, I have mirrored all the appropriate 
settings, but it's not working.


Calling SMJobBless succeeds, and the job is installed appropriately in 
/Library/LaunchDaemons and /Library/PrivilegedHelperTools. However, when 
I try to activate it via NSXPCConnection, all appears to be fine in the 
host app, but the helper tool never launches, as far as I can tell. I've 
run out of places to look for problems, so I need some more ideas on how 
to track down the problem. Any suggestions?


Thanks in advance!
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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: Debugging a privileged helper

2017-01-26 Thread John Brownie

Damien DeVille wrote:

Are you specifying the MachService you use for your XPC connection in
your launchd job?

I believe so. The launchd plist is:
==

"http://www.apple.com/DTDs/PropertyList-1.0.dtd";>



Label
org.sil.KLMHelper
MachServices

org.sil.KLMHelper


Program
/Library/PrivilegedHelperTools/org.sil.KLMHelper
ProgramArguments

/Library/PrivilegedHelperTools/org.sil.KLMHelper



==

The code to connect to the helper is:
==
helperToolConnection = 
NSXPCConnection.init(machServiceName: toolIdentifier, options: 
NSXPCConnection.Options.privileged)
helperToolConnection?.remoteObjectInterface = 
NSXPCInterface.init(with: Keyboard_Layout_HelperProtocol.self)

helperToolConnection?.invalidationHandler = {
self.helperToolConnection?.invalidationHandler = nil
OperationQueue.main.addOperation({
self.helperToolConnection = nil
})
}
==
where toolIdentifier is "org.sil.KLMHelper"

The code that invokes the code is like this:
==
let connection = connectionManager.helperToolConnection
let proxy = 
connection?.remoteObjectProxyWithErrorHandler { (error) in

NSApp.presentError(error)
} as! Keyboard_Layout_HelperProtocol
let authorization = connectionManager.authorization
// Call the proxy with the appropriate code
proxy.authenticatedCreateDirectory(url: location, 
authorization: authorization) { handler($0, $1) }

==

All of this is derived from Even Better Authorization Sample, translated 
to Swift.

--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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: Debugging a privileged helper

2017-01-27 Thread John Brownie

Stephane Sudre wrote:

Have you tried removing the Program entry?
That's produced, as far as I can tell, by the SMJobBless process. The 
file I pass is:



"http://www.apple.com/DTDs/PropertyList-1.0.dtd";>



Label
org.sil.KLMHelper
MachServices

org.sil.KLMHelper





It's added to the binary with the linker flag -sectcreate __TEXT 
__launchd_plist (path to the file). The launchd plist is exactly 
analogous to the tool that is already working, just the identifiers changed.

--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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


Table selection and bindings

2017-02-14 Thread John Brownie
I have an NSTableView in a document window, and a utility window which 
functions as an inspector, so its content is bound to the selected 
object in the table in the document window. Everything seems fine, but 
there is a place which doesn't function as I expect.


In the inspector, I can change the display name of the object, which 
makes the table drop its selection, so that nothing is selected any 
more. All OK, but the tableViewSelectionDidChange: delegate method isn't 
called in this instance. In a way, I can see that it's not the user 
changing the selection, but the problem becomes that now the inspector 
is still pointed at an object, but there's no selection, and the logic 
goes badly wrong.


Am I doing things incorrectly, or is there something that I can do to 
ensure that the change to the underlying array shown by the table 
triggers a selection change?

--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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: Table selection and bindings

2017-02-14 Thread John Brownie
OK, that makes sense. Tracing through, I do have a reloadData call, so 
I'll ensure that the selection gets maintained after that.


Yes, there is a mixture of data source and bindings, with the table view 
relying on data source and a bit of KVO, while the inspector relies on 
bindings. Things get rather messy with both the document window and the 
inspector panel having tabbed interfaces, meaning that I keep having to 
check which tab is active in order to activate the appropriate views. It 
may well be that I could do it all with bindings, but, with it all 
working (more or less), I don't want to break it. When I get that far in 
the Swift rewrite, then I can poke at it some more in the hope of making 
it cleaner.


Hopefully all will be well, so thanks for the pointers.

John

Quincey Morris <mailto:quinceymor...@rivergatesoftware.com>
14 February 2017 at 20:45

+1 what Keary said.

But there’s another question, which is why your selection is changing 
at all when you edit the object it represents. One possibility is that 
you’re invoking a reloadData on the table view when updating your 
model. If you do that, you must also re-establish the desired 
selection after the reload. Or, if you’re simply replacing the entire 
underlying array with a new instance that contains the modified 
object, the table view might treat that as a reload, depending on how 
your table view content is connected to your data model.


So, I think you are probably doing something “incorrectly”, in the 
sense that you need a lighter hand on the model update, or you need an 
extra step at the end of the update. Currently, it sounds like you are 
effectively but unintentionally clearing the selection 
programmatically, leading to the situation Keary describes.


___

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/john_brownie%40sil.org

This email sent to john_brow...@sil.org
Keary Suska <mailto:cocoa-...@esoteritech.com>
14 February 2017 at 19:25

If you are otherwise getting delegate calls when you manually (i.e. 
NOT programmatically) change the selection, then you are running into 
the situations where notifications are not sent when programmatic 
selection changes are made. The only way around this is to watch 
directly for selection changes, which you may be able to accomplish 
either by observing selectedRowIndexes of NSTableView or 
selectionIndex(es) of an NSArrayController that the table view is bond to.


HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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/john_brownie%40sil.org

This email sent to john_brow...@sil.org


--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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: Responder Chain Confusion

2014-09-07 Thread John Joyce

On 2014/09/08, at 8:49, dangerwillrobinsondan...@gmail.com wrote:

> 
> 
> 
> 
>>> On 2014/09/08, at 3:16, Kyle Sluder  wrote:
>>> 
>>> On Sep 7, 2014, at 9:24 AM, dangerwillrobinsondan...@gmail.com wrote:
>>> 
>>> Hi all
>>> 
>>> I just spent a bit of time poking around the responder chain and nil 
>>> targeted actions. 
>>> I built a view controller and a view hierarchy with controls that should be 
>>> configurable. 
>>> When instantiating the view controller the interface allows configuring the 
>>> action SEL of the controls. Reuse is the goal of course. 
>>> I know 10.10 changes things greatly for view controllers. But on 10.9 
>>> that's not there. 
>>> 
>>> Anyway, I need to insert the view controller into the responder chain 
>>> between its top level view and that view's superview. 
>>> That wasn't too bad. Implement the missing reference to the vc in a view 
>>> subclass and give the vc a callback when the view is in place. 
>>> 
>>> But what I found while tinkering is that for non-document based apps from a 
>>> vanilla project template there was no next responder for the window or the 
>>> NSApplication instance. 
>>> I had a method in the app delegate that I was trying to reach via nil 
>>> targeted action. It couldn't get there. 
>>> So I set the window nextResponder to the app and the app to the app 
>>> delegate. I also made the app delegate an NSResponder subclass. 
>>> 
>>> It feels like overkill. 
>>> Am I missing something simple?
>> 
>> IIRC, the window is not supposed to have a nextResponder. Conceptually, the 
>> next responder of a window is its delegate, and the next responder of an 
>> application is *its* delegate, but there is no requirement that these 
>> objects are instances of subclasses of NSResponder. Therefore the responder 
>> chain mechanism manually jumps from the window to its delegate, then to the 
>> application, and finally to the app’s delegate. (It also inserts window 
>> controllers as well as the shared NSDocumentController instance if one has 
>> been created.)
>> 
>> If the message never reached your app delegate, I suspect you failed to 
>> patch the view controller’s nextResponder in correctly.
>> 
>> --Kyle Sluder
> 
> I figured as much. It  seemed like none of that should be necessary normally. 
> But why would it be able to send standard responder messages like the 
> orderOut: action message to nil and reach the window?
> I must be inserting it wrongly into the responder chain. 
> 
> The docs describe exactly what everyone said here. 
> My app delegate does implement the selector. 
> I even exposed it in the header. 
> It is an action message. 
> So without doing anything special I should be able to send it right up the 
> chain and reach the app delegate. 
> The docs even state ( in the Cocoa Event Handling Guide, the others gloss 
> over this) that a window delegate and app delegate do not need to be 
> NSResponder descendants. 
> 
> I will look at this with an even simpler test app and see what's going on. 
> 
> I think you're right that I borked the responder chain insertion. 
> Without inserting the controller into the responder chain, should the view 
> follow the normal behavior of having its superview has nextResponder? 
> 
Ok, I re-read the docs. 

I found the solution I needed, without inserting anything into the responder 
chain.
I was doing this, and that was why I felt I needed to insert the vc into the 
responder chain. I even set the vc’s nextResponder to the window, which should 
have shortened the trip slightly, but the action message stopped at the window. 
(the self.negativeResponseAction is a configurable SEL property on the vc, the 
method call is in the vc’s action method of the control inside the vc’s view 
hierarchy)

BOOL performed = [sender 
tryToPerform:self.negativeResponseAction with:sender];

For what I want to do, vend a view with some controls whose actions are 
configurable, the approach that works gracefully is this:

BOOL performed = [[NSApplication sharedApplication] 
sendAction:self.negativeResponseAction to:nil from:sender];

In true Cocoa fashion, if it is taking a lot of effort and many lines of code, 
we are probably doing something wrong and there is probably a short simple 
solution, even if it isn’t immediately obvious.
The second method is clearly and explicitly documented to do things the way the 
Event Handling Guide says the responder chain should work for actions.
The first method is a lot less less documented and makes no assurances in the 
NSResponder docs about what it will or will not do beyond sending to the 
nextResponder. (one would think that should be fine from the docs, but the 
second method is clearly documented to do the right thing and it works well for 
nil-targeted action)

For whatever reason, tryToPerform:with:  does not work to forward message up 
the chain.
Sending sendAction:to:from: to the NSApp works like a charm.




Re: MapKit location authorization

2014-09-19 Thread John Tsombakos
You also need to add items to your Info.plist file:

NSLocationAlwaysUsageDescription

and/or

NSLocationWhenInUseUsageDescription

On Sep 19, 2014, at 2:01 PM, Gerriet M. Denkmann  wrote:

> 
> So I put it into viewDidLoad of the view controller for the MapView.
> 
> But:
> 
> authorizationStatus = kCLAuthorizationStatusNotDetermined
> locationServicesEnabled = YES
> 
> so I do (as recommended):
> [ self.locationManager requestWhenInUseAuthorization ];
> 
> Now I would expect a panel to come up, asking the user "Do you want to allow 
> this app to use Location Services?"
> But nothing is seen (iOS 8.0).
> 
> And when I ask the manager for a location, I just get nil.
> 
> Later on I get: locationManager:didChangeAuthorizationStatus: 
> kCLAuthorizationStatusNotDetermined
> 
> and: "Trying to start MapKit location updates without prompting for location 
> authorization."
> 
> Not very useful.
> 
> 
> Kind regards,
> 
> Gerriet.

___

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

Odd bug in HIThemeDrawWindowFrame on a retina display

2014-09-26 Thread John Weeks
I need to draw a bitmap image of a utility window title bar. I am using 
HIThemeDrawWindowFrame to draw into a CGBitmapContext at double resolution. I 
am testing this code on OS X 10.9.4 using a fake retina display (Displays 
settings, Resolution: Scaled, selecting a (HiDPI) setting).

On the fake retina display, the code draws a very odd-looking doubled titlebar 
with two close boxes instead of drawing a hi-resolution titlebar. It seems like 
it must be a bug in HIThemeDrawWindowFrame() because if I change 
kThemeUtilityWindow to  kThemeDocumentWindow, it draws perfectly.

Is there a way around this? Should I be using some sort of more-modern API to 
do this? Every bit of code I've found via Google seems to draw UI elements 
using HITheme APIs.

Thanks for any insight,
John Weeks
___

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: A Stack of Editors

2014-10-04 Thread John Joyce

> On Oct 4, 2014, at 11:27 AM, Charles Jenkins  wrote:
> 
> I just asked a question about the NSStackView, but perhaps I’m looking at the 
> wrong control altogether.  
> 
> What I’m trying to make is a scroll view containing a vertical stack of 
> editors for RTF subdocuments. Each of the text views should size itself to 
> fit the width of the scroll view, but grow vertically as much as necessary to 
> display its full content.
> 
> The more I think about it, the more I think what I need is a single-column 
> table view within which each cell holds a text editor. But each row, text 
> view, and text container should resize to fit the text held within. How can I 
> achieve that?
> 
> —
> 
> Charles Jenkins

Are you trying to use NSTextFields or NSTextViews? Either way, you will 
probably want to enable them to scroll as vertical height on a screen is 
limited.
At some point you will probably need to scroll vertically in the RTF document, 
unless you have some limit on the actual amount of text and you know the screen 
size of all users in advance.
You don’t want a window that exceeds the vertical height of a screen and you 
have no way to know what size screen might be used in advance.

NSStackView in a scroll view should be easier in some ways than NSTableView (if 
you want vertical resizing easily)
You could also do a NSSplitView with custom splitters.
However, it really sounds like you should consider a master-detail design if 
possible.
With say a table view to the left that is for selecting a section to work on, 
then the section displayed to the right.
You could also do a master-detail design with NSTabView. (even tabless, using a 
custom tab selector of some sort)
___

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: system sounds in iOS

2014-12-21 Thread John Joyce
You could try the free download (or in-browser JavaScript version) of a simple 
sound fx generator called Bfxr at www.bfxr.net 

> On Dec 21, 2014, at 3:53 AM, Maxthon Chan  wrote:
> 
> There is nothing preventing you from pointing a microphone and hitting record 
> button. If you can find some device, preferably mechanical, that produces 
> those sounds point a microphone at it and use Garageband to touch it up a 
> little bit.
> 
> If you have you can also make your own sound effects with your preferred 
> instrument. I have kept my MIDI keyboard just for this purpose, creating 
> alert chords for my apps.
> 
>> On Dec 21, 2014, at 02:28, Carl Hoefs > > wrote:
>> 
>> On Dec 19, 2014, at 11:12 PM, Donald Hall  wrote:
>> 
>>> I want to play a sound indicating that the user has tried to type a 
>>> non-allowed character (e.g. a letter where a number is needed) in 
>>> conjunction with "textField:textField 
>>> shouldChangeCharactersInRange:replacementString:” I was thinking of 
>>> “tink.caf” or “tock.caf”
>> 
>> 
>> #import 
>> #import 
>> 
>> AudioServicesPlaySystemSound(1057);
>> 
>> -Carl
>> 
>> 
>> ___

___

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

Bindings and Editing in a row

2015-02-17 Thread John MacMullin
Ok with programmatic bindings, I have:

1.   on the interface.

2.  In set up:
NSButtonCell *recCell11 = [NSButtonCell new];
[recCell11 setButtonType:NSSwitchButton];
[recCell11 setTitle:NULL_STRING];
[recCell11 setImagePosition:NSImageOnly];
[recCell11 setEditable:YES];
[[transTableView tableColumnWithIdentifier:@"11"]setDataCell:recCell11];
 [[transTableView tableColumnWithIdentifier:@"11"]setEditable:YES];

Plus my bindings in all columns.

3.  Also, in set up:

[transTableView setDelegate:self];
[transTableView setDataSource:self];

4.  Later in the code:

- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row
{
if (tableView) {
if (row >=0) {
return YES;
}
}
return YES;
}

5. Commented Out in the code:

/*

- (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn 
*)tableColumn row:(NSInteger)row
{
NSLog(@"shouldEditTableColumn");
if ([tableView tag] == 10 ) {
if (([tableColumn identifier] == @"11") && (row >= 0)) {
return YES;
} else {
return NO;
}
}
return NO;
}
*/

and 6. My:

- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object 
forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row

which works just fine.


So it appears that I don’t need shouldEditTableColumn because of the bindings.  
Where is this in the docs? (rather than random cocoa sources).

If I take out the following:

- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row
{
if (tableView) {
if (row >=0) {
return YES;
}
}
return YES;
}

I can’t select any row.  So it would appear that some of the table view methods 
operate independently of the bindings.  Where is this documented?


Best regards,

John MacMullin
___

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: Bindings and Editing in a row

2015-02-18 Thread John MacMullin
Actually, I did put in the NSLOG’s in the shouldEditTableColumn and it never 
“fired” no matter what I did, hence my question about the need and where 
documented.

I did find in the docs the statement to the effect that setObjectValue, as a 
datasource method, can run without the other datasource methods and with 
bindings.

The other I cannot find in the docs.  You would think that these intertwined 
relationships would be set out in the docs in a tidy fashion.

On Feb 17, 2015, at 3:51 PM, Quincey Morris 
 wrote:

> On Feb 17, 2015, at 12:35 , John MacMullin  wrote:
>> 
>> So it appears that I don’t need shouldEditTableColumn because of the 
>> bindings.  Where is this in the docs? (rather than random cocoa sources).
> 
> I’m not sure it’s got anything to do with bindings. Configuring table views 
> is just a bit messy, probably because they’ve evolved so much over the years.
> 
> If the delegate method is absent, then I’d expect the “Editable” checkbox on 
> the table column in IB to control the behavior. It’s certainly possible that 
> some bindings options may further restrict editability, and if you have a 
> NSArrayController between the table and its data model, it may also have 
> settings that affect editability.
> 
> The delegate method is likely intended to cover cases where the editability 
> is determined per-row, or by some other factor that isn’t easy to express in 
> IB, array controllers or bindings.
> 
>> If I take out the following:
>> 
>> - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row
>> {
>>if (tableView) {
>>if (row >=0) {
>>return YES;
>>}
>>}
>>return YES;
>> }
>> 
>> I can’t select any row.  So it would appear that some of the table view 
>> methods operate independently of the bindings.  Where is this documented?
> 
> It shouldn’t be necessary to have this method just to enable selection, and 
> it’s got nothing to do (intrinsically) with bindings. You’ve got some other 
> problem that’s interfering.
> 
> For example, if you have the table’s “selected row indexes” binding bound to 
> a property that doesn’t actually save the selection persistently, it’ll seem 
> like selection doesn’t work (though in such a hypothetical scenario, it is 
> working, but just getting cleared later, before you notice).
> 
> Tracking down misbehaviors in table views can be painful, because there are 
> lots of places to check, and no clear indication of what to look for. 
> Generally, you just need to persevere, perhaps with some judicious NSLogging 
> to check your assumptions about what’s happening and when.

Best regards,

John MacMullin
___

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: Unknown class ‘MyCustomView', using 'NSView' instead

2015-02-22 Thread John Joyce
Why not use a framework ?
This is exactly why they exist. To hold resources that can't be in a lib. 
Xcode 6 makes frameworks easy. 

Thanks!
John Joyce

Sent from my iPhone

> On 2015/02/22, at 20:17, Erwin Namal  wrote:
> 
> Thank you for your reply.
> I already use both Other linker flags “-ObjC” and “-all_load” in the library, 
> in its bundle target (though it is useless I think) and in the application 
> including the library and the bundle with the nib.
> Then, I load the nib in the bundle by using :
> 
>> initWithNibName:nibName bundle:libraryBundle
> 
> The other linker flags did solve the issue of categories in the library not 
> visible in the application.
> The thing I don’t understand is that I get the warning, but my application 
> works fine. It shouldn’t if NSView was indeed used instead of MyCustomView.
> 
> Where do you put your linkerhack class ? In the library or in the app ?
> 
> Thanks for your help
> – E

___

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: Runtime message on Yosemite seems spurious?

2015-03-19 Thread John Brownie

On 20/03/2015 8:29, Graham Cox wrote:

Several of my apps are writing this to the console on Yosemite:

"Layout still needs update after calling -[NSScrollView layout].  NSScrollView or 
one of its superclasses may have overridden -layout without calling super. Or, something 
may have dirtied layout in the middle of updating it.  Both are programming errors in 
Cocoa Autolayout.  The former is pretty likely to arise if some pre-Cocoa Autolayout 
class had a method called layout, but it should be fixed."

I'm not subclassing NSScrollView and none of these apps use autolayout as such 
- they use the legacy struts-and-springs though I understand they are 
translated to autolayout in the modern OS. Can I safely ignore this, as it 
seems ot be a spurious message, or is it really trying to tell me something 
important?


I see the same thing. My research suggested that you can ignore it, and 
it's probably somewhere in Apple's code.


John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics  | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
___

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: Finder not responding to [NSRunningApplication activateWithOptions]

2015-04-08 Thread John Joyce

> On Apr 8, 2015, at 11:38 PM, Ken Thomases  > wrote:
> 
> On Apr 8, 2015, at 9:19 AM, Tomáš Znamenáček  > wrote:
> 
>> I should have mentioned that Finder behaves unlike other apps in this
>> regard. If I do the same with any other app, the app is correctly focused,
>> stealing focus from whatever app was focused before. (And the menu bar on
>> the display “gets focus”, too. Gets opaque, anyway.)
> 
> In the Finder, the desktop can be the main/key window.  For example, you can 
> cycle to it using Command-`.
> 
> Regards,
> Ken
> 
I NEVER noticed that before.
It’s weird because it IS a window, but it doesn’t order above others, so it 
isn’t totally obvious that the desktop has focus, and because its window level 
is so low, if you have multiple windows from other apps open, it’s extra not 
obvious.

Wow. This is a nice trick to know, but mostly not useful if you cannot see what 
you are selecting with the keyboard. Kind of scary actually to now realize this 
behaves this way. (it certainly explains curiously named items on my desktop 
over the years, and I have  weird feeling it’s been like this for forever and a 
day…)

So sounds like the trick is the window ordering, but that’s hard to tell with 
the desktop.

As a workaround though
[[NSWorkspace sharedWorkspace] launchApplication:@"Finder.app"];

Seems to do what Tomas is asking for.
Even selecting desktop first, the launching an app with this as the only thing 
in applicationDidFinishLaunching: brings Finder to the front with the front 
most (non desktop) window selected.

___

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: Yet more new information. Was: Re: Weird UITableView problem

2015-04-30 Thread John Tsombakos
My two cents.. I just tried this on a MacPro, 10.10.3 and Xcode 6 (6.3.1) and 
no matter which device I run in the simulator and scale factor, i can see all 
the items in the list. If looking at the iPad Air, thye all fit on the screen 
without scrolling. Smaller devices I have to scroll the table view.


> On Apr 30, 2015, at 10:44 AM, William Squires  wrote:
> 
> Okay, I've now tried this on Xcode 5 and 6, and on 10.8.5 and 10.10.3. Here's 
> my synopsis:
> 
> * Happens only with UITableView
> * Happens on simulator if set for any device (except iPad?) that has retina 
> display
> * Does not happen if set for a non-retina device.
> * Unknown if this happens on real devices (retina or not).
> * Happens regardless of the scale factor of the simulator display if the Mac 
> does not have a retina display. Unkonwn what happens if your Mac does have a 
> retina display (I don't have one.)
> * Happens with Swift or ObjC project
> * If set for iPad Air, all the rows are "available", plus about 3 to 4 blank 
> ones - this happens regardless of the scale factor (by "available", meaning 
> you can see them, or scroll down to see them.) If the scale factor is set to 
> see all the simulator screen, then the (simulated) UITableView has no 
> scroller and you can see all 20 of the rows, plus 3 blank ones (the rows are 
> there, but have no cell.textLabel.text)
> 
> This is a fairly easy project to duplicate. Just create a "Single View" iOS 
> project with target iOS 7+, for Universal, and either ObjC or Swift. Add a 
> UITableView to the main view, set your view controller to implement 
> UITableViewDelegate and UITableViewDataSource. Connect the outlets to the 
> view controller in IB. Set up some "content" (an array of 20 or so items), 
> and feed it to the UITableView via tableView:numberOfRowsInSection: and 
> tableView:cellForRowAtIndexPath: then set your target device to iPad air, and 
> then again to some iPhone (say, 5s, or 6) that has a retina display.
> 
> If possible, I'd like someone to try this on an actual iPhone, as well as to 
> try it on the simulator on an iMac that does have a retina display.
> 
> 
> On Apr 28, 2015, at 11:45 AM, William Squires  wrote:
> 
>> Thinking this was a Swift problem, I recreated the project, but with ObjC as 
>> the language. I set up the UI the same as with the Swift project. It too, 
>> only shows a subset of the array, only this one shows 15 rows, not 13. 
>> Here's the ViewController.m
>> 
>> //
>> //  ViewController.m
>> //  SimpleObjCTable
>> //
>> //  Created by William Squires on 4/28/15.
>> //  Copyright (c) 2015 William Squires. All rights reserved.
>> //
>> 
>> #import "ViewController.h"
>> 
>> @interface ViewController ()
>> 
>> @property NSArray *dwarves;
>> 
>> @end
>> 
>> @implementation ViewController
>> 
>> - (void)viewDidLoad
>> {
>> [super viewDidLoad];
>> self.dwarves = [NSArray arrayWithObjects:@"Sleepy",
>>   @"Sneezy",
>>   @"Bashful",
>>   @"Happy",
>>   @"Doc",
>>   @"Grumpy",
>>   @"Dopey",
>>   @"Thorin",
>>   @"Dorin",
>>   @"Nori",
>>   @"Ori",
>>   @"Balin",
>>   @"Dwalin",
>>   @"Fili",
>>   @"Kili",
>>   @"Oin", // These are not shown.
>>   @"Gloin",
>>   @"Bifur",
>>   @"Bofur",
>>   @"Bombur",
>>   nil];
>> 
>> // Do any additional setup after loading the view, typically from a nib.
>> }
>> 
>> - (void)didReceiveMemoryWarning
>> {
>> [super didReceiveMemoryWarning];
>> 
>> // Dispose of any resources that can be recreated.
>> }
>> 
>> #pragma mark "UITableView Methods"
>> 
>> -(NSInteger)tableView:(UITableView *)tableView 
>> numberOfRowsInSection:(NSInteger)section
>> {
>> NSInteger theCount = [self.dwarves count];
>> 
>> NSLog(@"theCount = %ld", theCount);
>> return theCount;
>> }
>> 
>> -(UITableViewCell *)tableView:(UITableView *)tableView 
>> cellForRowAtIndexPath:(NSIndexPath *)indexPath
>> {
>> NSLog(@"indexPath.row = %ld", indexPath.row);
>> UITableViewCell *cell = [tableView 
>> dequeueReusableCellWithIdentifier:@"SimpleTableIdentifier"];
>> if (cell == nil)
>> {
>> cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
>> reuseIdentifier:@"SimpleTableIdentifier"];
>> }
>> cell.textLabel.text = [self.dwarves objectAtIndex:indexPath.row];
>> return cell;
>> }
>> 
>> @end
>> 
>> running it gives me (in the debug console) 4 instances of "theCount = 20", 
>> followed by 15 lines of "inde

Re: static analyzers says I'm leaking, I _think_ I'm not

2015-05-06 Thread John McCall
> On May 6, 2015, at 1:57 PM, Michael David Crawford  
> wrote:
> I've had problems in the past where I failed to understand the Cocoa
> ownership conventions, I'm willing to grant that could be the case.
> 
> I know for sure that the analyzer enforces the naming conventions,
> that is, the exact same function names in C or C++ won't yield that
> same warnings as "alloc", "new" or "copy" would in Objective-C.
> 
> I'm reluctant to use ARC because in my honest opinion, ARC will get
> the leaks and most out of the crashes out of skanky code.  If you
> don't use ARC, you get them out by fixing the skank:
> 
>  "Dave, why do you add twelve extra bytes to all of Spellswell's allocations?"
> 
>  "That was so Spellswell would stop crashing."  Facepalm.
> 
> // LifeGrid.h
> @property (assign, nonatomic) GridCycler *cycler;
> 
> // Lifegrid.m - init
> self.cycler = [[GridCycler alloc] initWithGrid: self];  // Potential
> leak of an object
> if ( nil == self.cycler ) goto cycler_failed;
> 
> // dealloc
> [self.cycler release];
> 
> Expanding the "potential leak" message yields:
> 
> 1. assuming 'self' is not nil
> 
> 2. method returns Objective-C object with +1 retain count
> 
> 3. Object leaked: allocated object is not references later in this
> execution path and has a retain count of +1.
> 
> Isn't that what I want?  I should be taking ownership of it with
> "alloc/initWithGrid".
> 
> (initWithGrid doesn't do a cyclic retain.)

“cycler” is really a strong property (because you release its value in 
-dealloc), but you’ve declared it as assign, which means the synthesized setter 
won’t retain the new value or release the old value.  One way of looking at 
this is that the setter takes its argument at +1 and has a precondition that 
the property is currently set to nil.  Another way of looking at it is that the 
setter is buggy.

You should probably make the property readonly and just directly assign to the 
ivar in -init.

John.
___

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: Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar?

2015-05-21 Thread John McCall
> On May 21, 2015, at 4:44 PM, Graham Cox  wrote:
>> On 22 May 2015, at 3:02 am, Jens Alfke  wrote:
>> 
>>> Now that I have a path forward and understand why things are what they are, 
>>> this brings up the wonderful speed issue of "how much slower is property 
>>> access vs ivar access”.
>> 
>> Yeah, I think we’ve had some vigorous debates about this topic in the past.
> 
> 
> Anecdotally, with some coarse measurements to confirm it, I changed a bunch 
> of code in -initWithCoder: to set ivars directly instead of using the 
> property accessors (or -set:). For a very large object graph - I’m 
> talking hundreds of thousands of objects - the speed-up was dramatic. 
> Dearchiving that large file went from 11 MINUTES to about 2 seconds.
> 
> Because -initWithCoder: is an init method, setting ivars directly is par for 
> the course, and at that time there can’t be any KVO observations depending on 
> the property accessors, so it’s fine. However, if you have autosynthesized 
> all your properties, to be completely safe and future-proof, you probably 
> shouldn’t be doing this, even though right now the ivar names are 
> predictable. That means that performance could be an issue with 
> autosynthesized properties.

The synthesized ivar name algorithm is not an implementation detail.  It is 
fully specified as follows: the compiler prepends a ‘_’ to the property name.  
Do not worry about future releases of the language changing the ivar name.

John.
___

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

How to debug a binding exception?

2015-06-02 Thread John Brownie
Things are working mostly fine with my app, but I discover an exception 
if I close a document which has not been saved, and elect to discard the 
document:


* thread #1: tid = 0x51dfe8, 0x7fff9393b743 
libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread', 
stop reason = breakpoint 1.1

frame #0: 0x7fff9393b743 libobjc.A.dylib`objc_exception_throw
frame #1: 0x7fff8e722eed CoreFoundation`+[NSException 
raise:format:] + 205
frame #2: 0x7fff93556896 
Foundation`-[NSObject(NSKeyValueObserverRegistration) 
_removeObserver:forProperty:] + 604
frame #3: 0x7fff935565d9 
Foundation`-[NSObject(NSKeyValueObserverRegistration) 
removeObserver:forKeyPath:] + 114
frame #4: 0x7fff9355b8e7 Foundation`-[NSKeyValueNestedProperty 
object:didRemoveObservance:recurse:] + 291
frame #5: 0x7fff935567a1 
Foundation`-[NSObject(NSKeyValueObserverRegistration) 
_removeObserver:forProperty:] + 359
frame #6: 0x7fff935565d9 
Foundation`-[NSObject(NSKeyValueObserverRegistration) 
removeObserver:forKeyPath:] + 114
frame #7: 0x7fff96503dae AppKit`-[NSController 
removeObserver:forKeyPath:] + 96
frame #8: 0x7fff964fdde8 AppKit`-[NSBinder 
_updateObservingRegistration:] + 818
frame #9: 0x7fff9674f367 AppKit`-[NSBinder 
releaseConnectionWithSynchronizePeerBinders:] + 44
frame #10: 0x7fff964ef380 
AppKit`-[NSObject(_NSBindingAdaptorAccess) _releaseBindingAdaptor] + 196
frame #11: 0x7fff96412e3a AppKit`-[NSView 
_releaseBindingAdaptor] + 69
frame #12: 0x7fff96411af7 AppKit`-[NSView 
_finalizeWithReferenceCounting] + 1863

frame #13: 0x7fff9641137e AppKit`-[NSView dealloc] + 151
frame #14: 0x7fff964eed24 AppKit`-[NSControl dealloc] + 169
frame #15: 0x7fff9394e89c 
libobjc.A.dylib`objc_object::sidetable_release(bool) + 236
frame #16: 0x7fff93934e8f libobjc.A.dylib`(anonymous 
namespace)::AutoreleasePoolPage::pop(void*) + 575

frame #17: 0x7fff8e5f96f2 CoreFoundation`_CFAutoreleasePoolPop + 50
frame #18: 0x7fff9352e762 Foundation`-[NSAutoreleasePool drain] 
+ 153

frame #19: 0x7fff96413cc1 AppKit`-[NSApplication run] + 800
frame #20: 0x7fff96390354 AppKit`NSApplicationMain + 1832
  * frame #21: 0x000100186ff2 MyApp`main(argc=3, 
argv=0x7fff5fbff700) + 34 at main.m:13

frame #22: 0x7fff9350d5c9 libdyld.dylib`start + 1

My problem is that I don't know what binding would be causing the 
problem. Is there a way to find out which it is?


John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics  | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
___

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: How to debug a binding exception?

2015-06-02 Thread John Brownie

___

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

Another bindings question

2015-06-02 Thread John Brownie
The exception I was getting was from a binding established in IB, which 
is a bit of a worry, but it prompts me to ask whether I'm pursuing the 
right road.


What I have is an NSTableView (still cell-based, moving to view-based is 
further down the track), and then a bunch of buttons that need to be 
enabled only when there is a selection in the table. Binding to the 
selection property of the array controller with NSNotNil doesn't work. 
Binding to selectionIndexes.count (which works as 0 or 1) does work, but 
this is the binding where I get the exception. Finding that binding was 
trial and error, as I haven't really found a good guide to this whole 
area, so I would be happy to have a better solution.


John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics  | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
___

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: Another bindings question

2015-06-02 Thread John Brownie

___

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

Going back to non-ARC

2015-06-12 Thread John Brownie
Having worked with ARC code for a long while, I discovered an 
incompatibility with a library that means I have to convert to non-ARC 
code. Of course, there's no guidelines for this, so I'm just wondering 
what the rule is for the dealloc method. I would release all non-nil 
instance variables, and I think I should be releasing strong properties. 
What about IBOutlets that are declared as strong? Do they have to be 
released as well, or is there some magic in nib handling that makes that 
unnecessary?


Any advice welcome before I go back to testing and looking at leaks, etc.

John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics  | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
___

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: Going back to non-ARC

2015-06-12 Thread John Brownie

On Fri Jun 12 2015 18:45:49 GMT+1000 (PGT) Ken Thomases wrote:

On Jun 12, 2015, at 3:18 AM, John Brownie  wrote:


Having worked with ARC code for a long while, I discovered an incompatibility 
with a library that means I have to convert to non-ARC code.

Before we address the how, let's make sure of the why.  What is the nature of 
this incompatibility?  ARC was designed so that code compiled with ARC can 
interoperate just fine with code compile with manual retain/release, and vice 
versa.  So, there should be no need to abandon ARC just because of a 
third-party library.  What lead you to believe there is such a need?


Well, it's the Nano library for handling various data structures such as 
NS collections, CF collections, strings, etc, in C++. It works fine 
without ARC, but falls in a heap when trying to compile for 
Objective-C++. I saw my options as either backing out of ARC, or writing 
a bunch of shims in plain C to avoid Objective-C++, and the former 
seemed easier. My model code is mostly C++, with Objective-C for the 
view and controller parts.


John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics  | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
___

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: Going back to non-ARC

2015-06-12 Thread John Brownie

On Fri Jun 12 2015 21:11:26 GMT+1000 (PGT) Alex Zavatone wrote:

Got a link to the iibrary?


https://github.com/refnum/nano/tree/master

John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics  | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
___

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: Going back to non-ARC

2015-06-13 Thread John Brownie
After much trial and error, I seem to have everything working again, 
back under ARC. The problem was a macro that was too ambitious for Cocoa:


NCFOBJECT_OPERATOR(NSArrayRef)

which expands to:

 inline NCFObject(NSArrayRef cfObject) {
 InitializeSelf(cfObject, false);
 }
 inline operator NSArrayRef(void) const {
 return((NSArrayRef) mObject);
 }

(NSArrayRef is defined as typedef NSArray *NSArrayRef;)

It was being used for NSArray, NSData, NSDate, NSDictionary, NSNumber 
and NSString. It works for Core Foundation objects, since they can all 
be cast to CFTypeRef, but it seems to require more specific casts in 
Cocoa to get the bridging to work under ARC.


I fixed it by manually expanding it for each case, with appropriate 
casts, such as:


inline NCFObject(NSArrayRef cfObject) {
InitializeSelf((__bridge CFArrayRef)cfObject, false);
}
inline operator NSArrayRef(void) const {
return (__bridge NSArrayRef)mObject;
}

Nano itself needs a fair bit of work to compile with ARC, so I'm only 
patching this one show-stopper for me. Hopefully it's sufficient to make 
it all work for me, but limited testing shows that earlier memory errors 
have been fixed by this.


Thanks for the pointers that eventually led to a solution.

John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics  | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
___

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: Swift 2.0

2015-07-02 Thread John Tsombakos
There’s this:

The Swift Programming Language (Swift 2 Prerelease)

https://itunes.apple.com/us/book/swift-programming-language/id1002622538?mt=11 



> On Jul 2, 2015, at 12:59 PM, William Squires  wrote:
> 
> There is (or was) a PDF you could get in the Bookstore.app direct from Apple 
> vis-a-vis the original Swift (1.0). Has this document been updated (for Swift 
> 2.0) or even a new "changes to Swift" document, or are we waiting for the 
> "official" release of Xcode 7, and/or a new OS X 10.11 or some such?
> ___
> 
> 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/johnt519%40gmail.com
> 
> This email sent to johnt...@gmail.com

___

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

Drag highlight problems

2015-07-19 Thread John Brownie
I have a window with many (up to around 80) views which can be targets 
of drag and drop (they can also be sources, but that doesn't appear to 
be relevant). Each has a suitable tracking area. I respond to drag enter 
and drag exit, and then to drag operation. The basics of the code is below.


- (NSDragOperation)draggingEntered:(id)sender
{
self.dragHighlight = YES;
[self setNeedsDisplay:YES];
return NSDragOperationGeneric;
}

- (void)draggingExited:(id)sender
{
self.dragHighlight = NO;
[self setNeedsDisplay:YES];
}

- (BOOL)performDragOperation:(id)sender
{
self.dragHighlight = NO;
NSPasteboard *pboard = [sender draggingPasteboard];
NSArray *classArray = @[[NSString class]];
NSDictionary *dictionary = @{};
NSArray *draggedItems = [pboard readObjectsForClasses:classArray 
options:dictionary];

if (draggedItems != nil && [draggedItems count] > 0) {
// Handle the drag, which will ensure that setNeedsDisplay 
is set...

return YES;
}
[self setNeedsDisplay:YES];
return NO;
}

Everything works correctly except for the drag highlight. Sometimes, and 
I haven't been able to work out what the sequence is, the drag highlight 
will be left on after the drop happens. The problem seems to be some 
sort of race condition, but I'm finding it hard to track down. Putting 
logging in each of the three methods makes the problem go away, so that 
isn't useful.


Am I doing something wrong?

John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics  | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
___

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

Drag highlight problems

2015-07-19 Thread John Brownie
I have a window with many (up to around 80) views which can be targets 
of drag and drop (they can also be sources, but that doesn't appear to 
be relevant). Each has a suitable tracking area. I respond to drag enter 
and drag exit, and then to drag operation. The basics of the code is below.


- (NSDragOperation)draggingEntered:(id)sender
{
self.dragHighlight = YES;
[self setNeedsDisplay:YES];
return NSDragOperationGeneric;
}

- (void)draggingExited:(id)sender
{
self.dragHighlight = NO;
[self setNeedsDisplay:YES];
}

- (BOOL)performDragOperation:(id)sender
{
self.dragHighlight = NO;
NSPasteboard *pboard = [sender draggingPasteboard];
NSArray *classArray = @[[NSString class]];
NSDictionary *dictionary = @{};
NSArray *draggedItems = [pboard readObjectsForClasses:classArray 
options:dictionary];

if (draggedItems != nil && [draggedItems count] > 0) {
// Handle the drag, which will ensure that setNeedsDisplay 
is set...

return YES;
}
[self setNeedsDisplay:YES];
return NO;
}

Everything works correctly except for the drag highlight. Sometimes, and 
I haven't been able to work out what the sequence is, the drag highlight 
will be left on after the drop happens. The problem seems to be some 
sort of race condition, but I'm finding it hard to track down. Putting 
logging in each of the three methods makes the problem go away, so that 
isn't useful.


Am I doing something wrong? I'm on OS X 10.10.4, Xcode 6.4.

John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics  | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
___

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: Drag highlight problems

2015-07-20 Thread John Brownie

On Mon Jul 20 2015 20:39:12 GMT+1000 (PGT) Uli Kusterer wrote:

On 20 Jul 2015, at 04:36, John Brownie  wrote:

Everything works correctly except for the drag highlight. Sometimes, and I 
haven't been able to work out what the sequence is, the drag highlight will be 
left on after the drop happens. The problem seems to be some sort of race 
condition, but I'm finding it hard to track down. Putting logging in each of 
the three methods makes the problem go away, so that isn't useful.

Am I doing something wrong? I'm on OS X 10.10.4, Xcode 6.4.

Looking at my code here: 
https://github.com/uliwitness/UliKit/blob/master/UKFilePathView.m, I also clear 
my drag highlight in concludeDragOperation:.
Thank you, that seems to work. Why it does is beyond me, though. There's 
only one place where I set the dragHighlight property to YES, and that's 
dragEntered. Do the events sometimes come out of order, or more than 
once? Could I get dragEntered, then performDragOperation, then another 
dragEntered? Why else would setting it to NO in two different methods be 
the solution?


John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics  | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
___

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 printing

2015-07-30 Thread John Brownie
One of my users has reported a crash in printing, and I don't really 
know what could be triggering it. This is the error:


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

VM Regions Near 0xf8:
-->
__TEXT 0001082eb000-000108524000 [ 2276K] 
r-x/rwx SM=COW  /path/to/binary


Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.print.framework.PrintCore0x00010f8141f5 
PJCSessionHasApplicationSetPrinter + 4
1   com.apple.print.framework.Print.Private0x00012332648a 
0x12331 + 91274
2   com.apple.AppKit  0x000109346857 
-[NSWindowController _windowDidLoad] + 586
3   com.apple.AppKit  0x00010932eb83 
-[NSWindowController window] + 110
4   com.apple.AppKit  0x000109447e9d -[NSPrintPanel 
beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:] 
+ 533
5   com.apple.AppKit  0x000109447970 
__91-[NSConcretePrintOperation 
runOperationModalForWindow:delegate:didRunSelector:contextInfo:]_block_invoke388 
+ 149
6   com.apple.AppKit  0x000109447861 
__91-[NSConcretePrintOperation 
runOperationModalForWindow:delegate:didRunSelector:contextInfo:]_block_invoke 
+ 55
7   com.apple.AppKit  0x0001094467cb 
-[NSConcretePrintOperation 
runOperationModalForWindow:delegate:didRunSelector:contextInfo:] + 621
8   My.app.signature   0x0001083d00a8 
-[MyWindowController printDocument:] + 3553
9   com.apple.AppKit  0x0001094ea0b1 
-[NSToolbarButton sendAction:to:] + 75
10  com.apple.AppKit  0x0001093dae5a 
-[NSToolbarItemViewer mouseDown:] + 4981
11  com.apple.AppKit  0x00010994b2dc -[NSWindow 
_reallySendEvent:isDelayedEvent:] + 14125
12  com.apple.AppKit  0x0001092dac86 -[NSWindow 
sendEvent:] + 470
13  com.apple.AppKit  0x0001092d7212 -[NSApplication 
sendEvent:] + 2504
14  com.apple.AppKit  0x000109200b68 -[NSApplication 
run] + 711
15  com.apple.AppKit  0x00010917d244 
NSApplicationMain + 1832

16  libdyld.dylib 0x00010c0945c9 start + 1

My best guess is that I'm passing something wrong, but, not being able 
to reproduce the crash myself, I can't tell what to look for. Any 
suggestions?


John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics  | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
___

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: NSPDFImageRep Memory Leak?

2009-09-08 Thread John Calhoun

On Sep 8, 2009, at 5:08 AM, DairyKnight wrote:

NSPDFImageRep *pdfImgRep = [[NSPDFImageRep alloc] initWithData:[page
dataRepresentation]];


Check [page dataRepresentation] above.

Pre-SnowLeopard the NSData returned was not autoreleased and so needed  
to be released by the caller.  This was not consistent with other  
AppKit -[xxx dataRepresentation] calls.


In SnowLeopard, -[PDDPage dataRepresentation] is properly auto- 
released.  SnowLeopard PDF Kit though checks the compiler and  
continues the non-auto-prelease behavior for apps compiled before  
SnowLeopard.


The above applies to -[PDFDocument dataRepresentation] as well.

Check the PDFXxx headers, the behavior change is documented there.

John Calhoun—___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Anti-aliasing in Snow Leopard (10.6) PDFView

2009-09-08 Thread John Calhoun

On Sep 7, 2009, at 3:50 PM, Duncan McGregor wrote:


It used to be that PDFView anti-aliased nicely. Now it doesn't, at
least not for some files. Text and scans rendered in both the
PDKKitViewer and PDFLinker2 samples are horrible in 10.6.


Can you point to a specific PDF that shows this behavior?

John Calhoun—___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Does Mac OS X support interior pointers?

2009-09-08 Thread John Engelhart
On Sun, Sep 6, 2009 at 9:20 PM, Quincey Morris
wrote:

> On Sep 6, 2009, at 17:36, John Engelhart wrote:
>
>  So, since the Mac OS X documentation uses the term "interior pointer" in a
>> totally non-standard way, and I can't find anything wrt/ to what I'm looking
>> for, my question is:
>>
>> Does the Mac OS X garbage collector support interior pointers (as defined
>> at http://www.memorymanagement.org/glossary/i.html#interior.pointer )?
>>
>
> Huh?
>
> You know it doesn't. You've beaten up on GC before, with reference to
> *both* senses of "interior pointer".


To my recollection, I have never discussed this problem on the list.  I have
discussed the following: (both related to
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcUsing.html#//apple_ref/doc/uid/TP40008006-SW7)

1) The problems of "Mac OS X Interior pointers", in so far that the pointer
from [data bytes] does not keep 'data' live.
2) The compiler, in GC mode, generates code that is violates C99 section
6.2.4: Storage duration of objects.

Point 1 is not contested by anyone (in so far as I know). The only point of
contention is the degree that this causes problems.

Point 2 is not up for debate- One can write an example test case of
objective-c code that when compiled with -fobjc-gc, the assembly output from
the compiler can be checked to see if it violates section 6.2.4.  Whether or
not the assembly output violates 6.2.4 is unambiguous and not open to
interpretation.  The referenced Mac OS X GC section essentially says this is
what happens.  In fact, the referenced section effectively says that point 1
and 2 happen.

The problem I've brought up is neither point 1 or point 2.


>  I certainly hope this isn't the case because this essentially means that
>> it is fundamentally impossible to write programs that execute in a
>> deterministic fashion when using GC.  It is basically impossible to write
>> code that guarantees that the base pointer remains visible to the collector,
>> particularly when __weak and/or the optimizer is used.  Things work the vast
>> majority of the time because there is (usually) a very small window of time
>> where it could actually cause a problem and one of two things are true:  1)
>> When the compiler generates code that, as a side effect, only uses interior
>> pointers (this happens much, much more frequently than you would think),
>> there's "something" that covers this fundamental error with a base pointer.
>>  This is invariably due to a happy set of coincidences and rarely the
>> explicit, intentional result of the programmer. 2) The collector is not
>> collecting during the window of vulnerability.
>>
>
> You also know that no one else on this list agrees with you on this
> subject, so I don't understand why you're asking about it.
>

Well, since point 1 is (assumed) uncontested, that leaves point 2.

Those who disagree with me implicitly acknowledge

A) The compiler is generating code that violates the C standard.
B) Because of this, it significantly complicates writing code that uses
garbage collection.

... and I gotta say, hats off to those folks!  Even if you put A aside, that
still leaves the effects of B.  The dedication to make your life harder and
your programming more difficult just to 'be right' is impressive.  Garbage
collection is supposed to make things simpler and easier, after all.


> *Of course* every programmer explicitly and intentionally ensures that the
> lifetimes of "base" pointers continue for as long as "derived" or "interior"
> pointers need to be valid. That's the Mac OS X garbage collection
> architecture, for now.
>

>From this statement I'm going to assume that you have very little experience
with the back ends of compilers.  Either that or you didn't bother to read
my message before you responded.

You don't seem to understand that what you've just asserted is, for all
practical purposes (and especially once the optimizer kicks in), *IMPOSSIBLE
*.  For example:

// Assume that 'data' is a NSData that is a ASCII string of text.

NSData *data;
const char *cString = [data bytes];
size_t length = strlen(cString);
char cStringCopy[length];

for(NSUInteger x = 0UL; x < length; x++) { cStringCopy[x] = cString[x]; }

The non-declaration usage of '[]' is a pointer operator in C.  The use of
'cStringCopy' after the declaration is equivalent to '(&cStringCopy[0])'- a
pointer to the first (index 0) element of the array.  This means the for
loop is equivalent to:

for(NSUInteger x = 0UL; x < length; x++) { *(cStringCopy + x) = *(cString +
x); }

It's useful to

KVO can be unsafe in -init?

2009-09-08 Thread John Chang
Hi all,
Question: is it unsafe for some reason to be adding yourself as a KVO
observer during -init?

We have a singleton with an -init that looks something like this:
- (id)init
{

if ((self = [super init]))
{

_foo = [[NSMutableDictionary alloc] init];
_bar = [[NSMutableDictionary alloc] init];

[[XYZManager sharedManager] addObserver:self forKeyPath:@"allObjects"
options:NSKeyValueObservingOptionInitial context:NULL];

}
return self;

}
This code is running on iPhone OS. On some devices (we haven't been to
narrow this down), the last line of code is throwing an exception:

Sun Sep  6 13:41:26 unknown MyApp[1609] : *** Terminating app due to
uncaught exception 'NSInvalidArgumentException', reason: '***
-[NSCFDictionary setObject:forKey:]: attempt to insert nil key'


We know that [XYZManager sharedManager] can't be nil, since otherwise
-addObserver: would not be getting called, and the first line "if ((self =
[super init]))" ensures that self can't be nil. We're pretty sure
that [XYZManager sharedManager].allObjects is not nil, but even if it were
nil, that shouldn't cause an exception. -allObjects is a synthesized getter
with no dependent keys. No other threads are involved here.

So we're stumped as to why KVO is throwing an exception. The only theory is
that the NSKeyValueObservingOptionInitial option is causing KVO to do
something with self immediately, but self isn't fully "set up" yet. Though
it's unclear why in this particular usage that would be unsafe, or why it
would make any difference. Can anyone provide any insight?

Thanks,
/John
Stockholm, Sweden
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: KVO can be unsafe in -init?

2009-09-09 Thread John Chang


On 9 sep 2009, at 04.51, Graham Cox wrote:

Because you're trying to use a nil key with a dictionary. Why not  
set a breakpoint on objc_exception_throw and see where that is being  
attempted?


Because it's happening for some users and not in-house :)


On 9 sep 2009, at 05.02, Ken Ferry wrote:

Is your -observeValueForKeyPath: safe to be called with a partially  
set up object?


I don't think we're getting that far. (See below)

Do you have any subclasses of your object?  If so, - 
observeValueForKeyPath: is getting called on them before they've  
done their work in init.


No, it's a singleton. Basically it's a "manager" object that wants to  
continually monitor something else for changes. Also, -addObserver is  
the last line of code in -init, before the return.



On 9 sep 2009, at 05.03, Roland King wrote:

One thing to note, you're using a context of NULL, which I used to  
do all the time until I got badly bitten.


What would you recommend using as the context? I'm used to checking  
object/keyPath, though I noticed as you pointed out that the Xcode  
template does it with context.



On 9 sep 2009, at 05.09, Stephen J. Butler wrote:


Why do you think registering the observer is causing this exception?
There's nothing KVO related in this message.


Sorry, I was thinking of including the backtrace and I guess I didn't.  
In -init, -addObserver: is only called once, so we're pretty certain  
about the exact line of code that is being indicated here, unless the  
stack is lying.


Thread 0 Crashed:
0   libSystem.B.dylib   0x31dd594c __kill + 8
1   libSystem.B.dylib   0x31dd593a kill + 4
2   libSystem.B.dylib   0x31dd592e raise + 10
3   libSystem.B.dylib   0x31deccf8 abort + 36
4   libstdc++.6.dylib 	0x374ef840  
__gnu_cxx::__verbose_terminate_handler() + 588

5   libobjc.A.dylib 0x300166b8 _objc_terminate + 160
6   libstdc++.6.dylib 	0x374ecf34 __cxxabiv1::__terminate 
(void (*)()) + 76

7   libstdc++.6.dylib   0x374ecfac std::terminate() + 16
8   libstdc++.6.dylib   0x374ed060 __cxa_rethrow + 108
9   libobjc.A.dylib 0x30016554 objc_exception_rethrow + 4
10  Foundation	0x305049f6 -[NSObject 
(NSKeyValueObserverRegistration)  
addObserver:forKeyPath:options:context:] + 342
11  FooApp 	-[XYZManager init] (in FooApp) +  
548 0x1000 + 375876
12  FooApp 	+[XYZManager sharedManager] (in  
FooApp) + 124 0x1000 + 379580


Sun Sep  6 13:41:26 unknown FooApp[1609] : *** Terminating app  
due to uncaught exception 'NSInvalidArgumentException', reason: '*** - 
[NSCFDictionary setObject:forKey:]: attempt to insert nil key'


- (id)init
{
if ((self = [super init]))
{
_foo = [[NSMutableDictionary alloc] init];
_bar = [[NSMutableDictionary alloc] init];

[[XYZManager sharedManager] addObserver:self 
forKeyPath:@"allObjects"
options:NSKeyValueObservingOptionInitial context:NULL];
}
return self;
}

///

What I'm hearing from the various responses is that as a rule, it's  
not safe to expose self at all during initialization, which makes  
sense, though in this case, we're stumped as to why it blows up, since  
by the time we call -addObserver:, self is already valid. In the  
interim, we're just going to catch that exception. But it's worrisome  
that we don't understand the root cause. We're thinking of refactoring  
this class in the future anyway, so this problem could magically go  
away. Maybe we can just chalk it up to KVO voodoo.


Thanks for the responses,
/John

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: KVO can be unsafe in -init?

2009-09-09 Thread John Chang


On 9 sep 2009, at 11.21, Mike Abdullah wrote:

Well I would question why you're calling +[XYZManager sharedManager]  
from within -[XYZManager init] like that. What if you change your  
init routine to:


Oops, sorry. It's actually two different classes which I renamed  
incorrectly for the purposes of this discussion.
-[HighLevelObjectDatabase init] wants to listen to  
[LowLevelObjectManager sharedManager] and observer any changes there.


/John

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: CAShapeLayer for Drawing Lines; Animations Skewed

2009-09-10 Thread John Harper


On Sep 10, 2009, at 7:20 PM, Christopher J Kemsley wrote:


CAShapeLayer with Path from PointA to PointB

In this method, I used a CAShapeLayer with the correct color and a  
1px width. I made a path between the two points.


For moves, I created another path representing the new position and  
used a CABasicAnimation to animate the "path" property.


This also 'works,' but also has a side-effect: A line, instead of  
animating from (oldPointA,oldPointB) to (newPointA,newPointB) would  
animate to (oldPointA,oldPointB) to (randomPoint,randomPoint) to  
(newPointA,newPointB)   (Note:  (aPoint,bPoint) represents a  
line/path from aPoint to bPoint)


yes, that looks like a bug, please file a radar so we can track it. (bugreport.apple.com 
)


for now I think you can get the right result by giving each line three  
points instead of two, the easiest way to do that is just add an extra  
point with the same coordinates as the end point.


John


___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: KVO can be unsafe in -init?

2009-09-11 Thread John Chang
Just to update you guys. We managed to reproduce the problem in-house and
catch it in the debugger. The backtrace looks the same as the one in the
auto-generated crash reports.
(gdb) bt
#0  0x02546004 in ___TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION___ ()
#1  0x98c81f49 in objc_exception_throw ()
#2  0x00a258de in -[NSObject(NSKeyValueObserverRegistration)
addObserver:forKeyPath:options:context:] ()

The ah-ha is that KVO is catching and re-throwing exceptions in
-addObserver:.. If one sets a breakpoint in the code that gets called
indirectly, you'll get something much more interesting and sensible:

(gdb) bt
#0 -[LocalizedIndexedCollation _sectionTitleWithCollationString:]
#1 0x000d3d86 in -[LocalizedIndexedCollation
sectionForObject:collationStringSelector:]
#2 0x000d4335 in -[LocalizedIndexedSectionedList initWithObjects:key:]
#3 0x000d59fb in -[SectionedTableViewController setContent:]
#4 0x000cc347 in -[FooTableViewController reloadData]
#5 0x000ccb2e in -[FooTableViewController setContactGroup:]
#6 0x000cb07c in -[FooGroupsTableViewController
observeValueForKeyPath:ofObject:change:context:]
#7 0x00a76c1e in NSKVONotify ()
#8 0x00a12e2a in -[NSObject(NSKeyValueObserverNotification)
didChangeValueForKey:] ()
#9 0x00a34a47 in _NSSetUsingKeyValueSetter ()
#10 0x00a344c5 in -[NSObject(NSKeyValueCoding) setValue:forKey:] ()
#11 0x0008367b in -[BlahManager(NSKeyValueObserving)
observeValueForKeyPath:ofObject:change:context:]
#12 0x00a76c1e in NSKVONotify ()
#13 0x00a2702b in -[NSObject(NSKeyValueObserverRegistration)
_addObserver:forProperty:options:context:] ()
#14 0x00a25872 in -[NSObject(NSKeyValueObserverRegistration)
addObserver:forKeyPath:options:context:] ()

* yes, LocalizedIndexedCollation was my attempt to rewrite
UILocalizedIndexedCollation for OS 2.x compatibility

You just have to have a good intuition where to look in your own code, I
guess, since the crash logs and the debugger won't help much in this case.
The best clue comes from the exception itself, but unfortunately that's only
in the console log, not the crash reports -- at least not until iPhone OS
starts including "Application Specific Information" like Snow Leopard does.

Cheers,
/John
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Retaining a NSURL and retaining its -path

2009-09-12 Thread John Love
In my controller, one of my instance variables is a NSURL and I retain  
it because I pass it to a 2nd controller.  In my second controller, I  
extract [myURL path] and look at it in a secondary thread loop and  
everything works fine.  I began to think if I could eliminate that  
call to [myURL path] every time through that loop I would save "some"  
time.


My first attempt was to pass that NSURL in the same manner and then  
place the extracted [myURL path] into an instance variable of the 2nd  
controller.  Okay so far .. and then I assumed that if myURL was  
retained in the 1st controller, then "naturally" its NSString -path  
was also retained .. but it crashed with "release message sent to a  
already released object" (or something like that).  Only when I  
extracted the -path *and* retained it before I stored it as an  
instance variable of the 2nd controller did it work.


Basic question: if a parent object is retained, why isn't each sibling  
component object of that parent retained??


John Love
Touch the Future! Teach!



___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: KVO can be unsafe in -init?

2009-09-13 Thread John Chang


On 13 sep 2009, at 05.33, Jerry Krinock wrote:

I'd be interested to know how John is going to fix this problem.  I  
myself have used the performSelector:withObject:afterDelay:0.0  
solution in situations like this


I think the problem really only happens with the  
NSKeyValueObservingOptionInitial option, which causes KVO to make a  
bunch of calls to user code (with potentially lots of side effects)  
directly inside -addObserver:etc:etc:. So the afterDelay: idea  
wouldn't really help, since in both cases -addObserver: is going to be  
catching and rethrowing exceptions. (One of our guys noticed that the  
crash report had objc_exception_rethrow, instead of  
objc_exception_throw, which I never noticed until he pointed it out.)


The solution was to find and fix the root cause of the exception, but  
hunting down the source of the exception is the hard part. The above  
knowledge, however, should help in the future. We were absolutely down  
the wrong path in suspecting self and -init.


/John

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: How to determine if a PDFPage is image based? (A scanned page)

2009-09-14 Thread John Calhoun

On Sep 13, 2009, at 5:01 AM, DairyKnight wrote:

Is there a way to determine if a PDFPage contains only a picture?


You could see if NULL is returned for -[PDFPage string].  That sort of  
indirectly implies an image (or a blank page — or one perhaps with  
line art only ...).


John Calhoun—___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


app delegate +initialize

2009-09-22 Thread John Baldwin

I'm missing something in the loading of an application delegate.

In my MainMenu.xib file, the File's Owner delegate connection is set  
to an AppController object. File's Owner's class is set to  
NSApplication.


In the AppController class, a +(void)initialize method is defined.

The +(void)initialize method gets called and my initialization happens  
as expected on my development machine. Every time, it seems.


But on a second test machine, the method doesn't get called. Ever, it  
seems.


Both machines are running 10.5.8.

I can't figure out what I'm missing to get the AppController class  
loaded and initialized as planned. Could anyone point me in the right  
direction?


John



___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Exit screen saver programmatically?

2009-09-24 Thread John Horigan
If you send the unwanted events to ScreenSaverView parent of your view  
then it should terminate gracefully.


[super theEvent];


-- john

On Sep 24, 2009, at 1:14 AM, Gabriel Zachmann wrote:

Post a mouse down event and the sceensaver engine will remove it  
for you.


That is a good idea -- except I have no idea how to do that.
Could you give me a hint how to achieve that? (class / method names?)
(Sorry, for asking shuch a dumbquestion.)
BTW: just a mouse move event would suffice, is that possible, too?  
(that way, I wouldn't have to worry about coordinates)



It's possible; you'd have to discriminate based on the bundle  
identifier returned by the main NSBundle.



what exactly are you trying to accomplish?


I want to catch a few key events in my screen saver (like cursor  
keys, space, return),
but if the user clicks any other key, I want the screen saver to  
exit, just like other screen savers that don't catch any keyboard  
events.


So, right now, I tried this:

   if ( ! [self isPreview] )
   [NSApp terminate: self];

but this has the disadvantage in the following scenario:
1. User opens System Preferences / Screen Saver, and activates my  
screensaver

2. User clicks 'Test', my screen saver runs in full screen mode
3. User clicks any key (other than the few above mentioned ones)
Problem is: after that the System Preferences app is gone, too!

Currently, the complete key handling code in my screen saver looks  
like this:



- (void) keyDown: (NSEvent *) theEvent
{
   if ( [theEvent modifierFlags] & NSNumericPadKeyMask )
   {
   [self interpretKeyEvents: [NSArray arrayWithObject:theEvent] ];
   }
   else
   {
// exit gracefully
   if ( ! [self isPreview] )
   [NSApp terminate: self];
   }
}

- (IBAction) moveLeft: (id) sender
{
   ...
}




Eigentlich bin ich ganz anders, nur komme ich so selten dazu.
 ( Ödön von Horváth )

  http://zach.in.tu-clausthal.de







___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Remove NSTableView Default Selection

2009-09-24 Thread John McIntosh
Hello all. I am working on an application that contains a NSTableView.
The table view has a single column which display several options.
Based on the row that the user selects, something is displayed. When
the application is first launched, the first row in the table is
selected by default (but not processed as a selection because it was
not actually clicked). I want no rows to be selected when it is first
launched. So, the functionality is correct now, but I need the first
(or any other) row not to be preselected.

I have a button to clear the selection. In its code, I send a
deselectAll message to the table which correctly clears the selection.
I assumed that I could send the same deselectAll message in either an
awakeFromNib function or applicationDidFinishLaunching. However,
neither of these clears the selection.

I would greatly appreciate any advice. Thank you.

John
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Remove NSTableView Default Selection

2009-09-25 Thread John McIntosh
Perfect, thank you! I have the table bound to a core data source and
did not know about the "avoid empty selection" option in the
controller. Unckecking that box took care of it.

John

On Thu, Sep 24, 2009 at 10:12 PM, Jens Alfke  wrote:
>
> On Sep 24, 2009, at 5:07 PM, John McIntosh wrote:
>
>> I assumed that I could send the same deselectAll message in either an
>> awakeFromNib function or applicationDidFinishLaunching. However,
>> neither of these clears the selection.
>
> Make sure you've checked the table's "Empty" checkbox (allow empty
> selection) in the nib.
> Also, if there's a controller bound to the table, uncheck its "Avoid empty
> selection" checkbox.
>
> —Jens
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Creating a radar sweep effect

2009-09-26 Thread John Cebasek

Hi All:

I'm wondering what the best way to create a radar sweep effect is?  
(Like in old war movies?)


I was trying to create a shadow effect but that didn't look good as  
when the sweep line was at 0, 90, 180 or 270 degrees, the shadow  
wasn't very visible. And even using the shadow, it wasn't long enough  
with the values I tried. And I had tried afew.


I then tried the following:

CGContextStrokeEllipseInRect(context, squareRect);

//
// Draw the sweep
//
CGContextBeginPath(context);
CGContextSetLineWidth(context, 1.65);
// CGContextMoveToPoint(context, centerPoint.x, centerPoint.y);
CGContextSetRGBFillColor(context, 0.0, 1.0, 0.0, 1.0);  

	CGColorRef color = CGColorCreate(CGColorSpaceCreateDeviceRGB(),  
shadowColor);

CGContextSetShadowWithColor(context,

CGSizeMake(-2.0, 2.0),
5.0,
color);
CGColorRelease(color);

viewCoordinates[0] = centerPoint;

	viewCoordinates[1] = [self  
convertToViewCoordinatesFromPolarAngle:nDegree


withRadius:radius];

	viewCoordinates[2] = [self convertToViewCoordinatesFromPolarAngle: 
(nDegree - 5)


 withRadius:radius];

CGContextAddLines(context, viewCoordinates, 3);

CGContextClosePath(context);

CGContextSetFillColorWithColor(context, [UIColor greenColor].CGColor);

CGContextStrokePath(context);

In this code I was trying to get the triangle to be filled with a  
green colour, but that didn't work. But at least there's a triangle  
that is drawn where it should bet. (And yes I have read the various  
documentation, but nothing's jumped out as to what to use).


Can someone point me to a URL, sample code or make a (polite)  
suggestion?


Thanks in advance for your time

John

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


  1   2   3   4   5   6   7   8   9   10   >