Cannot Debug

2008-02-28 Thread Steve Cronin

Folks;

This is XC2.4.1 on Tiger 10.4.11.  (been at this level since 10.4.11)  
no recent system level changes.


I'm doing Cocoa application development and all things are proceeding  
normally when suddenly I can no longer run the debugger.
I have pretty stringent build rules but I get a good clean compile  
(no warnings).


I have done a full Clean and Rebuild but still get the same results...
I have restarted the machine but still get the same results...

I can compile and 'Run' just fineBUT when I try to 'Debug'  
this is what appears in the console:


tty /dev/ttyp1
Program loaded.
sharedlibrary apply-load-rules all
run
[Switching to process 1243 local thread 0xf03]
Running…
Pending breakpoint 1 - "[NSException raise]" resolved
Pending breakpoint 2 - "-[NSObject setNilValueForKey:]" resolved
Pending breakpoint 3 - "-[NSObject release]" resolved
1   AppKit.subproj/AppKitGlobals.m: No such file or directory.
in AppKit.subproj/AppKitGlobals.m
1   in AppKit.subproj/AppKitGlobals.m
1   in AppKit.subproj/AppKitGlobals.m
... (this last line will be repeated until I stop the process)

I see the frameworks at /System/Library/Frameworks  and they appear  
normal at least in a casual perusal...
AppKit; Foundation and CoreData are all in the 'Other Frameworks'  
Group and are NOT checked for inclusion.


I was not nor have been making app architectural changes for several  
days.  Just normal code level debugging.


Why does this only happen in Debug?
What has happened?

Any insight would be really appreciated!
Steve___

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]


How to debug a nib loading error?

2008-03-06 Thread Steve Cronin

Folks;

Tiger 10.4.11 -- XC 2.4.1
I'm baffled by an IB error.

Reasonable development has been on-going.
Pretty stringent Build Rules and no errors or warnings.
I decide to do a clean build, torch the app's prefs file and the  
CoreData store.

I want to focus on the initial installation phase of the app...

To my great surprise I cannot now get the app to launch successfully.  
It ran fine 15 minutes beforehand...


Regardless of whether I 'Run' or 'Debug' I get the exact same result:

I get all the way through the appDelegate's -awakeFromNib and the  
pref window opens (as I expect on first launch) but the debugger  
kicks in with the following:


#0  0x90a594c7 in objc_msgSend
#1  0xb7b8 in ??
#2  0x932849d8 in loadNib
#3	0x932843d9 in +[NSBundle(NSNibLoading)  
_loadNibFile:nameTable:withZone:ownerBundle:]
#4	0x9328403a in +[NSBundle(NSNibLoading)  
loadNibFile:externalNameTable:withZone:]

#5  0x93283f7c in +[NSBundle(NSNibLoading) loadNibNamed:owner:]
#6  0x93283cc3 in NSApplicationMain
#7  0x00405ffc in main at main.m:18

In the Console I see:
Normal log messages that I generate and expect (including the  
'end-of-awake-from-nib' stamp)

Program received signal:  "EXC_BAD_ACCESS".

I have the [NSException raise] as a Global breakpoint but it doesn't  
fire.


Using the po command I can tell that MainMenu is the nib involved;  
the prefs window is in a separate nib...


How do I track this down?
Steve

___

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: How to debug a nib loading error?

2008-03-06 Thread Steve Cronin

Jon;

Thanks for the quick response!!

If I set the NSZombieEnabled variable to YES I get the following:
#0  0x9282b36d in -[NSException raise]
#1  0x92852247 in +[NSException raise:format:]
#2  0x928da79b in logMessageAndRaise
#3  0x927dc8af in NSPopAutoreleasePool
#4  0x932849d8 in loadNib
#5	0x932843d9 in +[NSBundle(NSNibLoading)  
_loadNibFile:nameTable:withZone:ownerBundle:]
#6	0x9328403a in +[NSBundle(NSNibLoading)  
loadNibFile:externalNameTable:withZone:]

#7  0x93283f7c in +[NSBundle(NSNibLoading) loadNibNamed:owner:]
#8  0x93283cc3 in NSApplicationMain
#9  0x00405ffc in main at main.m:18
Console:
2008-03-07 01:33:24.728 XYZ[372] *** Selector 'release' sent to  
dealloced instance 0x1baba2c0 of class NSConcreteData.

Break at '-[_NSZombie release]' to debug.

NOTE:  I do an 'API' & and a Full-Text Search in the documentation  
for 'NSConcreteData' and there is nothing!  Not a single reference.   
Google yields more but NSConcreteData is definitely not used directly  
by my app.


*** How do I determine what 'instance 0x1baba2c0 of class  
NSConcreteData' is?


If I add a global breakpoint for -[NSZombie release] I get:
#0  0x928da958 in -[_NSZombie release]
#1  0x927dc8af in NSPopAutoreleasePool
#2  0x932849d8 in loadNib
#3	0x932843d9 in +[NSBundle(NSNibLoading)  
_loadNibFile:nameTable:withZone:ownerBundle:]
#4	0x9328403a in +[NSBundle(NSNibLoading)  
loadNibFile:externalNameTable:withZone:]

#5  0x93283f7c in +[NSBundle(NSNibLoading) loadNibNamed:owner:]
#6  0x93283cc3 in NSApplicationMain
#7  0x00405ffc in main at main.m:18
Nothing in the console.
How does this help me?  What is useful about this?  Is there a gdb  
command I should invoke on frame 0?


If I 'Enable Guard Malloc" the application takes over 15 minutes and  
finally appears to launch and but just seems to hang!

Nothing in the debugger or console

Thanks for your further consideration!
Steve


On Mar 7, 2008, at 12:44 AM, Jonathan Hess wrote:

I would start by debugging with the NSZombieEnabled environment  
variable set to YES. You can read about that environment variable  
here: http://developer.apple.com/technotes/tn2004/tn2124.html


If that doesn't work, I would try running with libgmalloc enabled.  
You can turn that on with "Enable Guard Malloc" in the Xcode "Run"  
menu.


Good Luck -
Jon Hess

On Mar 6, 2008, at 10:36 PM, Steve Cronin wrote:


Folks;

Tiger 10.4.11 -- XC 2.4.1
I'm baffled by an IB error.

Reasonable development has been on-going.
Pretty stringent Build Rules and no errors or warnings.
I decide to do a clean build, torch the app's prefs file and the  
CoreData store.

I want to focus on the initial installation phase of the app...

To my great surprise I cannot now get the app to launch  
successfully. It ran fine 15 minutes beforehand...


Regardless of whether I 'Run' or 'Debug' I get the exact same result:

I get all the way through the appDelegate's -awakeFromNib and the  
pref window opens (as I expect on first launch) but the debugger  
kicks in with the following:


#0  0x90a594c7 in objc_msgSend
#1  0xb7b8 in ??
#2  0x932849d8 in loadNib
#3	0x932843d9 in +[NSBundle(NSNibLoading)  
_loadNibFile:nameTable:withZone:ownerBundle:]
#4	0x9328403a in +[NSBundle(NSNibLoading)  
loadNibFile:externalNameTable:withZone:]

#5  0x93283f7c in +[NSBundle(NSNibLoading) loadNibNamed:owner:]
#6  0x93283cc3 in NSApplicationMain
#7  0x00405ffc in main at main.m:18

In the Console I see:
Normal log messages that I generate and expect (including the  
'end-of-awake-from-nib' stamp)

Program received signal:  "EXC_BAD_ACCESS".

I have the [NSException raise] as a Global breakpoint but it  
doesn't fire.


Using the po command I can tell that MainMenu is the nib involved;  
the prefs window is in a separate nib...


How do I track this down?
Steve

___

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/jhess%40apple.com

This email sent to [EMAIL PROTECTED]




___

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]


XCode3 & NSLog & Tiger compatibility

2008-03-15 Thread Steve Cronin

Folks;

I've finally begun to use XCode3 and I know I need to learn my way  
around the new world.


I have an existing Tiger project that I will be shipping under Tiger  
but I need to ensure Leopard compatibility.
So I can't convert it to the new world - I just need to be able to  
run/debug it.


So immediately I run into the changes to Run log -> Console.
OK - I try and understand what's going on but I can't seem to find  
anything useful which explains:


If you have line of Tiger Code:
NSLog(@"Hello World");

Where does this output appear in XCode3?
I can see it sometimes in the Console.app but not reliably...
(I have setup a database query for my 'Sender'.)
I can see it sometimes in the Console log in XCode but not reliably..

I can't change the statements to ASL based statements per above..

How can I best use XCode3 to accomplish this mission?
Thanks!
Steve

___

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]


CoreData code working on Tiger - not on Leopard

2008-03-18 Thread Steve Cronin

Folks;

I am now testing a Tiger application on Leopard and learning the new  
Leopard way at the same time.

I admit I have a lot of Leoparding to do!

I use Core Data (SQLite) pretty extensively on Tiger - life is good.

I take the project and run it without any changes to the model or the  
code and Core Date won't save to disk.


I load a set of data on initial launch and at the end of that process  
I have Core Data 'save'.

The data loading all appears to run fine:
			recX = [NSEntityDescription insertNewObjectForEntityForName:@"XYZ"  
inManagedObjectContext:moc];

[recX setValue:@"123" forKey:@"source"];
...

5 different entities and 1,000s of records..

I've looked over the 'Core Data - Release Notes' but I don't see  
anything that seems to indicate a model conversion or persistant  
store conversions I have not made any changes (no versioning...)


Here's the 'save' code:
- (void) updateCoreData {
NSManagedObject *moc = [self managedObjectContext];
[moc processPendingChanges];
if ([moc commitEditing]) {
NSError *error;
if ([moc save:&error])  {
if (error!=nil) {

On Leopard in the 'processPendingChanges' invocation I get the  
following:


0   0x900ef0f4 in ___TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION___
#1  0x93d680fb in objc_exception_throw
#2	0x9649a2a5 in -[NSManagedObjectContext 
(_NSInternalChangeProcessing) _processRecentChanges:]

#3  0x964adbea in -[NSManagedObjectContext processPendingChanges]
#4  0x0002032e in -[AppDelegate updateCoreData] at AppDelegate.m:700

BTW:  I also get a similar error if, during the loading, I try to get  
a 'count' using a FetchTemplate with a null predicate (works on Tiger)

It appears the fetch also causes a 'processRecentChanges)

What am I missing?

Thanks for your help!
Steve
___

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]


XCode3 errors on startup

2008-03-18 Thread Steve Cronin

Folks;

When I start XCode3 in Leopard I am seeing the following in Console.app.

Any ideas on what is going on?
Steve


3/18/08 8:27:39 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x2963030, has non-zero refcount = 1
3/18/08 8:27:39 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x2963d90, has non-zero refcount = 1
3/18/08 8:27:39 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x2963030, has  
non-zero refcount = 1
3/18/08 8:27:39 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x2963d90, has  
non-zero refcount = 1
3/18/08 8:33:16 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x31cfed0, has non-zero refcount = 1
3/18/08 8:33:16 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x3725640, has non-zero refcount = 1
3/18/08 8:33:16 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x30ed7e0, has non-zero refcount = 1
3/18/08 8:33:16 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x31a9610, has non-zero refcount = 1
3/18/08 8:33:16 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x31cfed0, has  
non-zero refcount = 1
3/18/08 8:33:16 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x3725640, has  
non-zero refcount = 1
3/18/08 8:33:16 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x30ed7e0, has  
non-zero refcount = 1
3/18/08 8:33:16 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x31a9610, has  
non-zero refcount = 1
3/18/08 8:33:18 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x318bda0, has non-zero refcount = 1
3/18/08 8:33:18 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x3245320, has non-zero refcount = 1
3/18/08 8:33:26 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x3047dc0, has non-zero refcount = 1
3/18/08 8:33:26 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x308a7c0, has non-zero refcount = 1
3/18/08 8:33:18 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x318bda0, has  
non-zero refcount = 1
3/18/08 8:33:18 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x3245320, has  
non-zero refcount = 1
3/18/08 8:33:26 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x3047dc0, has  
non-zero refcount = 1
3/18/08 8:33:26 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x308a7c0, has  
non-zero refcount = 1
3/18/08 8:34:05 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x34d2750, has non-zero refcount = 1
3/18/08 8:34:05 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x34ef4d0, has non-zero refcount = 1
3/18/08 8:34:05 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x34d2750, has  
non-zero refcount = 1
3/18/08 8:34:05 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x34ef4d0, has  
non-zero refcount = 1
3/18/08 8:34:50 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x3292dd0, has non-zero refcount = 1
3/18/08 8:34:50 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x3295380, has non-zero refcount = 1
3/18/08 8:34:50 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x3292dd0, has  
non-zero refcount = 1
3/18/08 8:34:50 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x3295380, has  
non-zero refcount = 1

3/18/08 8:35:12 AM momc[685] momc compiling for 10.4 target
3/18/08 8:35:22 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x35848b0, has non-zero refcount = 1
3/18/08 8:35:22 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x358bc40, has non-zero refcount = 1
3/18/08 8:35:22 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x35848b0, has  
non-zero refcount = 1
3/18/08 8:35:22 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage: garbage ptr = 0x358bc40, has  
non-zero refcount = 1
3/18/08 8:35:50 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x3432ea0, has non-zero refcount = 1
3/18/08 8:35:50 AM Xcode[110] Xcode(110,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x345e130, has non-zero refcount = 1
3/18/08 8:35:50 AM [0x0-0xd00d].com.apple.Xcode[110] Xcode 
(110,0xb0103000) malloc: free_garbage:

Re: CoreData code working on Tiger - not on Leopard

2008-03-18 Thread Steve Cronin

Folks;

I have a little more data on this issue:

After I have done any insert, if I subsequently call - 
processPendingChanges  I get an error in CoreData.
There are no pending messages in the log and no custom catch blocks  
(other than what is show below).

The debugger halts on the @try command

The Code:
@try { [moc processPendingChanges]; }
@catch ( NSException *e ) {
		NSLog(@"%@: Caught %@: %@", NSStringFromSelector(_cmd), [e name],  
[e  reason]);

}

The Log:
Program received signal:  “EXC_BAD_ACCESS”.

The Stack:
#0  0x93d736ec in objc_msgSend
#1	0x9649aed1 in -[NSManagedObjectContext 
(_NSInternalChangeProcessing)  
_registerUndoForOperation:withObjects:withExtraArguments:]
#2	0x9649adef in -[NSManagedObjectContext 
(_NSInternalChangeProcessing) _registerUndoForInsertedObjects:]
#3	0x9649a038 in -[NSManagedObjectContext 
(_NSInternalChangeProcessing) _processRecentChanges:]

#4  0x964adbea in -[NSManagedObjectContext processPendingChanges]
#5	0x00089636 in +[DataImporter importSuppotDataInContext:] at  
DataImporter.m:75


The Maddening Part:
All of the code works like a charm on Tiger.

I know I must be missing something pretty basic in the Leopard world  
but I sure would appreciate a pointer to what that might be!


Thanks!
Steve

On Mar 18, 2008, at 2:33 AM, Steve Cronin wrote:


Folks;

I am now testing a Tiger application on Leopard and learning the  
new Leopard way at the same time.

I admit I have a lot of Leoparding to do!

I use Core Data (SQLite) pretty extensively on Tiger - life is good.

I take the project and run it without any changes to the model or  
the code and Core Date won't save to disk.


I load a set of data on initial launch and at the end of that  
process I have Core Data 'save'.

The data loading all appears to run fine:
			recX = [NSEntityDescription  
insertNewObjectForEntityForName:@"XYZ" inManagedObjectContext:moc];

[recX setValue:@"123" forKey:@"source"];
...

5 different entities and 1,000s of records..

I've looked over the 'Core Data - Release Notes' but I don't see  
anything that seems to indicate a model conversion or persistant  
store conversions I have not made any changes (no versioning...)


Here's the 'save' code:
- (void) updateCoreData {
NSManagedObject *moc = [self managedObjectContext];
[moc processPendingChanges];
if ([moc commitEditing]) {
NSError *error;
if ([moc save:&error])  {
if (error!=nil) {

On Leopard in the 'processPendingChanges' invocation I get the  
following:


0   0x900ef0f4 in ___TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION___
#1  0x93d680fb in objc_exception_throw
#2	0x9649a2a5 in -[NSManagedObjectContext 
(_NSInternalChangeProcessing) _processRecentChanges:]

#3  0x964adbea in -[NSManagedObjectContext processPendingChanges]
#4  0x0002032e in -[AppDelegate updateCoreData] at AppDelegate.m:700

BTW:  I also get a similar error if, during the loading, I try to  
get a 'count' using a FetchTemplate with a null predicate (works on  
Tiger)

It appears the fetch also causes a 'processRecentChanges)

What am I missing?

Thanks for your help!
Steve


___

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]


How to debug this Tiger release error?

2008-03-19 Thread Steve Cronin

Folks;

On Tiger, I have an app that has a popup button which allows a user  
to make a selection from a supporting array.
Once a new selection is made a collection of images are redraw in a  
view.

Has been working reasonably well...

Now sometimes, not consistently, when the selection is made the app  
will crash.

Sometimes I see the following in the console log:
2008-03-19 01:36:20.231 XYZ[3035] *[XYZMainWindowController  
setUserSelectedData]

XYZ(3035,0xa000d000) malloc: *** error for object 0x315730: double free
XYZ(3035,0xa000d000) malloc: *** set a breakpoint in szone_error to  
debug


I have the following environment variables set:
NSZombieEnabled(YES)
MallocStackLogging(1)

and these Global Breakpoints set:
[NSException raise]
szone_error
[NSObject setNilValueForKey]
-[_NSZombie release]
malloc_printf

The crash doesn't appear to fire any of these breakpoints and leaves  
only this meager trace in the stack:

#0  0x90a594c7 in objc_msgSend
#1  0x00315730 in ??
#2  0x90824f84 in __CFDictionaryDeallocate
#3  0x9080e0c6 in _CFRelease
#4  0x927dc96f in NSPopAutoreleasePool
#5  0x9328fab1 in -[NSApplication run]
#6  0x932839c0 in NSApplicationMain#7   0x00405ffc in main at main.m:18

If I step thru the code it eventually starts off into the assembly  
code for handling the interface and bindings and as you all are well  
aware there is an astonishing amount of such code underlying the Mac  
OS interface


If I pause the app and enable a breakpoint on [NSObject release] I  
get so many breaks that I just can't make any headway.
How DO I -- most efficiently -- figure out what dictionary is the  
culprit in frame 2 above?


Thanks for any help!
Steve

___

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]


__setjmp linking error in Leopard

2008-03-19 Thread Steve Cronin

Folks;

I'm trying to build a test case for a DTS support incident regarding  
an issue I posted earlier concerning CoreData in Leopard.
I have an existing app which compiles without inicident on both Tiger  
& Leopard.


To build the DTS test project, in Leopard I added the data model and  
several supporingt classes from this existing app, as well as the  
AppDelegate.

I stripped out all the unnecessary code.
I confirmed that all the build settings are identical.
I did not write a single line of new code.
I have the enable ObjC exceptions option turned ON.

When I compile on Leopard I get:
  "__setjmp", referenced from:
  +[XYZBase allActiveInContext:] in XYZBase.o
  +[XYZXBase allActiveInContext:] in XYZBase.o
  +[XYZManagedObject allInContext:] in XYZManagedObject.o
  +[XYZManagedObject allInContext:] in XYZManagedObject.o
  -[AppDelegate(PrivateUtilities) setupDefaultSQLLiteStore] in  
AppDelegate.o
  -[AppDelegate(PrivateUtilities) setupDefaultSQLLiteStore] in  
AppDelegate.o

  +[Owner loadOwnerInContext:] in Owner.o
  +[Owner loadOwnerInContext:] in Owner.o
  +[DataImporter importSupportDataInContext:] in DataImporter.o
  +[DataImporter importSupportDataInContext:] in DataImporter.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

Build failed (1 error)

All of the cited classes contain @try - @catch blocks.  Is there  
another compiler setting I an not aware of?


When I compile on Tiger: life is good!  No warnings, no errors, runs  
flawlessly...

Identical compiler settings!

Man I had no idea how much grief I was going to run into just to get  
running on Leopard!!!
I haven't even execised the bulk of the code  I'm just trying to  
get out of -init!


Thanks for any thoughts on this compiler matter!
Steve
___

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]


Consistent Contextual Menu in NSTableview

2008-04-21 Thread Steve Cronin

Folks;

I'm having some difficulty getting consistent contextual menu behavior  
in NSTableView.


In the Finder and iTunes (what I feel most users are familiar with) if  
a row is selected but the user causes a contextual menu on a different  
row then row selection changes.
(I don't want to start a UI flame about 'correctness') I'm only  
interested in consistency!!


NOTE: the contextual menu can appear by a right mouse click, a two- 
fingered tap, and a control-click which appear to be detected as  
different events (see below)


The base NSTableView class does NOT change the selection when a  
contextual click occurs on a row

If I sub-class and add:
- (void)rightMouseDown:(NSEvent *)theEvent {
	[self selectRow:[self rowAtPoint:[self convertPoint:[theEvent  
locationInWindow] fromView:nil]] byExtendingSelection:NO];

[super rightMouseDown:theEvent];
}

I get half-way home.  Now the right mouse click and the two-fingered  
tap will alter the selection.


BUT

the control-click does not.

The Cocoa adage, "if you are working too hard, you probably are" keeps  
rummaging around my brain


What is the preferred means to efficiently make consistent contextual  
menu behavior like Finder and iTunes?


Thanks,
Steve
___

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]


AppleScript - occasional crashes on Leopard

2008-04-22 Thread Steve Cronin

Folks;

I've seen some inconsistent behavior on AppleScript running under  
Leopard.


Here's an example:
...
NSString *theScript =@"some valid dynamic script text"
NSDictionary *errorDict = [NSDictionary dictionary];
	NSAppleScript *appleScriptObject = [[NSAppleScript alloc]  
initWithSource:theScript];	
	NSAppleEventDescriptor *eventDescriptor = [appleScriptObject  
executeAndReturnError: &errorDict];

...

will OCCASIONALLY crash at the NSAppleEventDescriptor specification:

#0  0x932c3d5c in getDescDataType
#1  0x932c7ab7 in aeCoerceDescInternal
#2  0x932cc055 in AECoerceDesc
#3  0x1d4a8150 in ComponentCoerceDesc
#4  0x1d48cbec in ASCompile
#5  0x903bacb8 in CallComponentFunction
#6  0x1d487ae2 in AppleScriptComponent
#7  0x1d4a3927 in AGenericManager::HandleOSACall
#8  0x903755cd in CallComponentDispatch
#9  0x953fc513 in OSACompile
#10 0x93e6edaf in -[NSAppleScript compileAndReturnError:]
#11	0x93e6f096 in -[NSAppleScript(NSPrivate)  
_executeWithMode:andReturnError:]

#12 0x93e6ee51 in -[NSAppleScript executeAndReturnError:]

Is there a new/better means in Leopard of accomplishing the execution  
of dynamic scripts?
NO the crash is NOT related to the validity of the script, of this I  
am absolutely certain!  (It only crashes sometimes using the same  
resulting script!!)

Is a dual processor Intel creating a risk here?
Is there something better I can do to handle the error?
Why should I have to use a @try block here?
I thought that was what the executeAndReturnError  parameter was  
for!!  But I don't get a chance to examine the errorDict.


It will crash only every so often
My hunch is that crashes are more likely when machine is under load  
and memory swapping might be involved.

This is running on a 4G MacBook...

Any wisdom appreciated!
Steve
___

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: AppleScript - occasional crashes on Leopard

2008-04-22 Thread Steve Cronin

NO threading involved here.
Just straight up Cocoa code...

Do you know enough about AS internals to read the stack trace and KNOW  
that the error is during compilation?

If so, why is the error not being propagated back thru errorDict?

And the biggest mystery (to me anyway)  why only sometimes?
Steve

On Apr 22, 2008, at 1:10 PM, Nick Zitzmann wrote:



On Apr 22, 2008, at 11:47 AM, Steve Cronin wrote:


will OCCASIONALLY crash at the NSAppleEventDescriptor specification:



Are you using NSAppleScript in the main thread? The only time I've  
ever seen compiling a script crash was when it was not running in  
the main thread.


Nick Zitzmann
<http://www.chronosnet.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 [EMAIL PROTECTED]


Re: AppleScript - occasional crashes on Leopard

2008-04-22 Thread Steve Cronin

Mark;

10 months after the first Leopard seed to developers,
6 months after commercial release,  and
after 2 system updates to the commercial product,
the message to developers using ANY AppleScript in Cocoa is:
"No Garbage Collection for you!"

Perhaps you can try and understand how this might be potentially  
irritating to some
Turning off Garbage collection has profound impacts on the rest of the  
code base NOT just AppleScript.
As I am sure you are aware, turning off Garbage Collection is WAY more  
than a compiler switch!


For my ongoing better understanding of Cocoa, could you provide a link  
to where I SHOULD have researched so that I would not end up in this  
corner.


Politely,
Steve

On Apr 22, 2008, at 2:53 PM, Mark Piccirelli wrote:


Is this a garbage-collected app? If so the crash is a known bug.

-- Mark

On Apr 22, 2008, at 10:47 AM, Steve Cronin wrote:

Folks;

I've seen some inconsistent behavior on AppleScript running under  
Leopard.


Here's an example:
...
NSString *theScript =@"some valid dynamic script text"
NSDictionary *errorDict = [NSDictionary dictionary];
	NSAppleScript *appleScriptObject = [[NSAppleScript alloc]  
initWithSource:theScript];	
	NSAppleEventDescriptor *eventDescriptor = [appleScriptObject  
executeAndReturnError: &errorDict];

...

will OCCASIONALLY crash at the NSAppleEventDescriptor specification:

#0  0x932c3d5c in getDescDataType
#1  0x932c7ab7 in aeCoerceDescInternal
#2  0x932cc055 in AECoerceDesc
#3  0x1d4a8150 in ComponentCoerceDesc
#4  0x1d48cbec in ASCompile
#5  0x903bacb8 in CallComponentFunction
#6  0x1d487ae2 in AppleScriptComponent
#7  0x1d4a3927 in AGenericManager::HandleOSACall
#8  0x903755cd in CallComponentDispatch
#9  0x953fc513 in OSACompile
#10 0x93e6edaf in -[NSAppleScript compileAndReturnError:]
#11	0x93e6f096 in -[NSAppleScript(NSPrivate)  
_executeWithMode:andReturnError:]

#12 0x93e6ee51 in -[NSAppleScript executeAndReturnError:]

Is there a new/better means in Leopard of accomplishing the  
execution of dynamic scripts?
NO the crash is NOT related to the validity of the script, of this  
I am absolutely certain!  (It only crashes sometimes using the same  
resulting script!!)

Is a dual processor Intel creating a risk here?
Is there something better I can do to handle the error?
Why should I have to use a @try block here?
I thought that was what the executeAndReturnError  parameter was  
for!!  But I don't get a chance to examine the errorDict.


It will crash only every so often
My hunch is that crashes are more likely when machine is under load  
and memory swapping might be involved.

This is running on a 4G MacBook...

Any wisdom appreciated!
Steve
___

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/markp%40apple.com

This email sent to [EMAIL PROTECTED]




___

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]


A Cocoa means to detect SysPref 'Enable access for assistive devices"

2008-04-23 Thread Steve Cronin

Folks;

Is there a straight Cocoa means to detect the System Preferences/ 
Universal Access setting for 'Enable access for assistive devices'?


I've found plenty of references on using Applescript to detect this  
setting.
The Cocoa Assistive API seems pretty extensive but I can't glean a way  
to just determine this setting using Cocoa...


I understand the potential 'admin' aspects of the setting.
All I want is a means to know what the current setting is.

Any links or code snippets appreciated!
Steve
___

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]


ManagedObjectContext save issue

2008-04-24 Thread Steve Cronin

Folks;

I have a CoreData model working reasonably under Tiger now moving to  
aggressive testing on Leopard.


I'm seeing something I don't believe I've never seen on Tiger...

The application has only one ManagedObjectContext.  This is  
established during the -awakeFromNib of the NSApp delegate.
Any other class which deals with the data does so by invoking [[NSApp  
delegate] managedObjectContext].


I have a popup menu that controls a primary selection for the user  
which restricts which objects are displayed currently.
Life is good.  Change the popup selection -->  see a different list of  
objects!.


There is a reasonably complex set of preferences which is managed by a  
single window with a toolbar and swapping in/out tabViews.
Nothing too outrageous but when the user closes this window I'm doing  
a save on the MgdObjCtx:


 (void) windowWillClose:(NSNotification *)notice {
NSManagedObjectContext *moc = [[NSApp delegate] managedObjectContext];
NSError *error = nil;
if ([moc commitEditing]) {
if ([moc hasChanges])  {
if (![moc save:&error]) {
NSLog(@"Error while saving\n%@", ([error localizedDescription] !=  
nil) ? [error localizedDescription] : @"Unknown Error");

}
}
} else {
//MOC CommitEdit problem ...
}
}

 I can change the popup's selection while the pref window is open and  
all is well, but as soon as I close the window I get a failure.

If I comment out the MgdObjCtx handling above, everything works fine.
So should I just let it go and trust CoreData?  But my brain wants to  
understand and my paranoia says I'm better off getting it written on  
the disk


The popup uses a fetchRequst to populate an array.
After closing the pref window (and thereby invoking the save above)  
the MgdObjCtx is still valid and the fetchReques is found and  
instantiated but the results are (null) whereas immediately before  
closing the window the results would have populated an array.


I know I must be missing some key aspect of save but I am seriously  
stumped here.


Thanks for any thoughts,
Steve

+ (ObjX *)lookupByName:(NSString *)name inContext: 
(NSManagedObjectContext *)moc {

NSError *error = nil;
NSArray *results = nil;
@try {
		NSFetchRequest * fReq = [[[moc persistentStoreCoordinator]  
managedObjectModel] fetchRequestFromTemplateWithName:@"findByObjXName"  
substitutionVariables:[NSDictionary dictionaryWithObject:name  
forKey:@"name"]];

results = [moc executeFetchRequest:fReq error:&error];
}


Before Window Closes:
2008-04-24 02:20:19.315 ABC[1427:10b] [ObjX lookupByName:inContext:]  
moc = 
2008-04-24 02:20:19.316 ABC[1427:10b] [ObjX lookupByName:inContext:]  
fReq =  (entity: ObjX; predicate: (ObjXName  
== "Test Pilots"); sortDescriptors: (null); limit: 0)
2008-04-24 02:20:19.339 ABC[1427:10b] [ObjX  
allMembersForObjXNamed:inContext:] this ObjX = < ObjX: 0x24e4260>  
(entity: ObjX; id: 0x24a4af0 

After Window Closes:
2008-04-24 02:20:36.147 ABC[1427:10b] [ObjX lookupByName:inContext:]  
moc = 
2008-04-24 02:20:36.148 ABC[1427:10b] [ObjX lookupByName:inContext:]  
fReq =  (entity: ObjX; predicate: (ObjXName  
== "Test Pilots"); sortDescriptors: (null); limit: 0)
2008-04-24 02:20:36.151 ABC[1427:10b] [ObjX  
allMembersForObjXNamed:inContext:] thisGroup = (null)



___

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]


Counting instances in Core Data

2008-04-29 Thread Steve Cronin

Folks;

I want to obtain a count of instances for a specific entity in stored  
in Core Data (SQLite)

In the archive I find this:


FROM : mmalcolm crawford
DATE : Sun Apr 02 21:21:45 2006
On Apr 2, 2006, at 11:16 AM, Frederick C. Lee wrote:

> How do you count (or determine empty) data from a persistent store  
(table)?


Execute a fetch for the entity in which you're interested, and count  
the returned array.



My question is: what is the most efficient fetch to pose given that  
every fetch is IO.
A given entity might have a lot of records so an array COULD be an  
unnecessarily large transaction...


Is there a best practice fetch for this 'get a count' purpose?
Steve
___

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]


InstantMessage Framework Question

2008-05-07 Thread Steve Cronin

Folks;

I've gotten the IM framework to respond to a few basic things but I'm  
puzzled by something simple...


I can determine the audio or video capabilities of buddies just fine   
BUT how do I figure out what my own capabilities are?
If I send the request for IMPersonCapabilitiesKey for my own screen  
name I get back a NULL.


What is the preferred way of determining the IMCapabilites for the  
machine my application finds itself running on?


BTW: 10.5 SDK deployment target of 10.4

Thanks,
Steve
___

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]


Cocoa string to carbon compatible C string

2008-05-11 Thread Steve Cronin

Folks;

I'm an ObjC guy who has to deal with some Carbon code that looks like  
this:


#define kVERSION "abc"
#define kPARTNUMBER "123"
...
if ( (p_flag = initSomeSystem (
kVERSION,   
kPARTNUMBER,
&errorCode))
== NULL) { 

What I have to do is makethe kPARTNUMBER a value that is settable by  
the user.

No problem collecting the data into NSString *partNumber.

So here's what I've done:

#define kVERSION"abc"
NSString * partNumber = [[blah blah] moreBlah];
.
	const char *  cPartNumber = [partNumber  
cStringUsingEncoding:NSUTF8StringEncoding];

if( (p_flag = initSomeSystem (
kVERSION,   
(char *) cPartNumber,
&errorCode))
   == NULL) { 

Is this correct?
Is there a better way?
When you use a directive like #define x "abc"  -> there is an implicit  
definition of x as a 'char *', is that correct?


Thanks for adding any clarity,
Steve


___

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 string to carbon compatible C string

2008-05-11 Thread Steve Cronin

Nick;

Thanks for the info, the deal is I don't have access to the source for  
'initSomeSystem'.
So I can't answer your question, other than to point out what does  
work..

I do know that ' #define kVersion "abc" ' creates a suitable string.

I'm trying to do the 'best' substitution I can with the fact that I  
have an NSString and no access to the called method.


Hence my original question as the result of a #define x "123" being a  
'char*'.

If that is true, then is the following the best solution?

#define kVERSION "abc"
NSString * partNumber = [[blah blah] moreBlah];
.
	const char *  cPartNumber = [partNumber  
cStringUsingEncoding:NSUTF8StringEncoding];

if( (p_flag = initSomeSystem (
kVERSION,   
(char *) cPartNumber,
&errorCode))
   == NULL) { 

Thanks,
Steve

On May 11, 2008, at 12:59 PM, Nick Zitzmann wrote:



On May 11, 2008, at 11:36 AM, Steve Cronin wrote:


Is this correct?
Is there a better way?



It depends. Does the code take a real C string (char array), or does  
it take an Str63 or Str255 or something? If the latter, then you  
need to use CoreFoundation to get a Pascal string from the NSString.


Nick Zitzmann
<http://www.chronosnet.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 [EMAIL PROTECTED]


NSDateFormatter -dateFromString Question

2008-07-15 Thread Steve Cronin

Folks;

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init] ;
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_0];
[dateFormatter setDateFormat:@"%m/%d/%Y %H:%M:%S %z"];
...
NSDate *myDate = [dateFormatter dateFromString:@"06/27/2008 02:51:52  
-0500"];


myDate = 06/27/20.

What am I missing here?  I expect the full date and time value to be  
reflected back in myDate...

I use 10_0 because I'm just more familiar..

I've tried adding:
[dateFormatter setDateStyle:NSDateFormatterLongStyle];
[dateFormatter setTimeStyle:NSDateFormatterFullStyle];

but that doesn't change anything...

Thanks for any help,
Steve

10.5.4 XC3.1
___

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

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

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

This email sent to [EMAIL PROTECTED]


Returning exactly what has been promised

2008-07-22 Thread Steve Cronin

Folks;

I find if I have a method which returns an NSString for example, that  
often, in the interior of that method I will use an NSMutableString to  
construct the string I intend to return.   My question concerns the  
actual final return statement.


Is there ANY reason to choose A over B?

A) return [NSString stringWithString:myWorkingMutableString];

B) return myWorkingMutableString;

It just kinda sticks in my craw me that I 'promised' an NSString and  
using (B) I don't return one.
Yeah I do understand inheritance and that a mutable entity  
isKindOfClass of the base class
I looking for reasons like edge cases, compiler optimization, error  
trapping, portability, etc..
Is there ANY benefit to the costs associated with the explicit  
declaration of (A)?


Thanks for helping me better understand!
Steve
___

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]


Is checking -count worth it?

2008-07-23 Thread Steve Cronin

Folks;

I'm really trying to learn how to write smart fast code.
Code that takes maximum advantage of all of the battle-tested  
intelligence built into Cocoa/ObjC2.
Now days with the "halo" and the "JesusPhone", I personally smell an  
excellent book opportunity...  But enough chit-chat.


I have a mutable array, M.  I want to remove an object, O, from M; O  
might not be in M.

M which is being constantly diminished could become empty.

Is this code worth it?
if ([M count]>0) [M removeObject:O];

OR should I just do
[M remove O];

I assume that I can't write better code than the removeObject's use of  
-indexOfObject  to determine the existence/location of O.
So there I get 'best performance' for free by just getting out of the  
way and letting Cocoa do its thing.


Is the only way to really tell to test?
Or is there a deeper insight that makes the choice clear?

Steve

___

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]


A Mac App & helper NSStatusItem - how to share preferences

2008-12-28 Thread Steve Cronin

Folks;

I have an application which will have an optional helper NSStatusItem.
The statusItem is a stand-alone application which can be installed as  
a LoginItem.


I want this status item to be able to read the preferences file from  
the application.
The user sets a number of preferences in the normal app which  
influence both how the app and the status item should behave.


I'm under the clear impression that I should not use the same  
bundleIdentifer for the application and the statusItem.

They could both be running at the same time...
Yet the bundleIdentifier seems to be the key to the file that  
[NSUserDefaults sharedDefaults] opens..


This not a managed environment nor is this issue related to users or  
hosts, so it doesn't seem that CFPreferences is called for (or even  
helps!)


How can I get the statusItem to read the application's preferences?

Thanks!
Steve

___

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: A Mac App & helper NSStatusItem - how to share preferences

2008-12-29 Thread Steve Cronin

Kyle;

Thanks for that pointer!  Based on the documentation you cited I've  
now got the reading of NSUserDefaults functioning!


In the hopes that it might be useful to someone else, I include these  
'Cocoa friendly' methods.
I grant that there are some improvements which could be made, I  
include them here in the spirit of helpfulness to the community

// myBundleID is a static string defined elsewhere

//retrieves the full user defaults dictionary
- (NSDictionary *) prefDictionary {
CFStringRef appBundleID = (CFStringRef)myBundleID;
	return (NSDictionary *)CFPreferencesCopyMultiple(NULL,  appBundleID,   
kCFPreferencesCurrentUser,  kCFPreferencesAnyHost);

}

//retrieves the string Value of a key  [full implementation of all the  
CFPropertyList types is left as an exercise for the reader)

- (NSString *) prefStringValueforKey:(NSString *)preferenceKey {
CFStringRef appBundleID = (CFStringRef)myBundleID;
	return (NSString*)CFPreferencesCopyValue((CFStringRef)preferenceKey,   
appBundleID,  kCFPreferencesCurrentUser,  kCFPreferencesAnyHost);	

}

//sets the value for a key
- (void) setPrefValue:(id)preferenceValue forKey:(NSString  
*)preferenceKey {

CFStringRef appBundleID = (CFStringRef)myBundleID;
	CFPreferencesSetValue((CFStringRef)preferenceKey,   
(CFPropertyListRef)preferenceValue,  appBundleID,   
kCFPreferencesCurrentUser,  kCFPreferencesAnyHost);	
	CFPreferencesSynchronize(appBundleID, kCFPreferencesCurrentUser,  
kCFPreferencesAnyHost);

}


Steve

On Dec 28, 2008, at 8:17 PM, Kyle Sluder wrote:

On Sun, Dec 28, 2008 at 8:41 PM, Steve Cronin   
wrote:
This not a managed environment nor is this issue related to users  
or hosts,

so it doesn't seem that CFPreferences is called for (or even helps!)


In fact, CFPreferences is exactly what you need.  Apple has some
sample code describing how to do exactly what you want:
http://developer.apple.com/documentation/CoreFOundation/Conceptual/CFPreferences/Tasks/UsingLowAPI.html#/ 
/apple_ref/doc/uid/20001170


--Kyle Sluder


___

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


Framework deployed to 'Resources' not 'Frameworks' in Contents

2008-12-29 Thread Steve Cronin

Folks;

I've got two targets built from the same project:  Big and Little

Big has many resources, source files, as well as several frameworks  
that are copied and then deployed to a 'Frameworks' directory in the  
app file's 'Contents'.
Little has many fewer of the resources and sources and only 1 of the  
framework.s.


Big is just fine: compiles without complaint and runs as expected.

Little's framework however gets deployed to the "Resources' directory  
on build.
Little will compile without any complaints but crash immediately on  
'dyld: Library not loaded: @loader_path/  Reason: image not  
found'.


I've been over the compiler settings until I'm nearly bonkers but I  
just don't see it


Can somebody please give me the conceptual whack I need...

Thanks!
Steve
___

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


respondsToSelector - #import OR compiler warnings?

2008-12-29 Thread Steve Cronin

Folks;

I have some methods which might be handled by one of several objects.
So I have a set of   if ( [objectX  
respondsToSelector:@selector(foo)] )  {... } else if ( [objectY  
respondsToSelector:@selector(foo)] ) {... } 


The functionality is fine but the compiler warnings for "no 'foo'  
method found" bug me.

Call me finicky if you want but I love spanking clean compiles.

I can, of course, silence the compiler by #import the headers for  
ObjectX and ObjectY.
But this leads to a level of dependancy and obfuscation that my gut  
doesn't like.

Later I find myself asking "Huh, I wonder why this header is here?"
Or worse: "Dang, I can't just re-use this object here without also  
dragging along that object?..arrghh"


So at the moment I add inline comments to the #imports statements to  
aid in these later questions but this feels lame and is tedious as  
well as error prone.


I realize that the runtime selection of the foo handler is the root  
issue and I cannot ignore this when I might reuse.

So I don't want to 'bury' the issue.
But a full header import for the sake of a method or two seems onerous.

What do others think of this dilemma?
Should I just be glad of the warnings and get over it?
Am I getting too worked up on the #import issue?
Is there a compiler flag I could toggle on/off to suit? (XC3.1)
Steve
___

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: respondsToSelector - #import OR compiler warnings?

2008-12-29 Thread Steve Cronin

Folks;

Thanks for the rapid and thought-provoking responses!!

Ken - I don't understand what you said about the method's signature's  
compliance with NSObject _protocol_.
I looked at the protocol definition in the documentation and I just  
don't understand well enough to see what I could do to "side-step" the  
warnings,

Would you be willing to spend another sentence or two on that?

Bill - OK I have a lot to learn - studying AppKit's delegate  
implementation is a to-do!  (gulp)
In the meantime, tweaked your snippet and just added this at the end  
of the header of the class where the -respondsToSelector: issue arose:


//respondsToSelector silencer - see -myMethodName
@interface NSObject (MyClassName)
- (id) foo;
@end

This silences the compiler without any #import being required in  
the .m file AND allows me to document to issue in the header where it  
seems to me it belongs. YAY!! Any downsides to this?
I assume I could implement this declaration with the actual return  
expected (e.g. (NSDictionary*)) and squeeze even more assistance out  
that hard-working compiler, right?


Thanks to all of you: Kyle, Graham, Ken and Bill for sharing your time  
and your knowledge!

Steve

___

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: respondsToSelector - #import OR compiler warnings?

2008-12-29 Thread Steve Cronin

Ken;

I think I get it now.  In the simple case you describe below, use:

someThing = [myObject performSelector:@selector(myMethod)] instead  
of  someThing = [myObject myMethod]


This seems quite useful!!  performSelector's more ambitious cousins  
seem a tad less 'friendly' but I get the point!


As always with you -> Quite Helpful!
Thanks,
Steve

On Dec 30, 2008, at 1:00 AM, Ken Thomases wrote:


On Dec 30, 2008, at 12:06 AM, Steve Cronin wrote:

Ken - I don't understand what you said about the method's  
signature's compliance with NSObject _protocol_.
I looked at the protocol definition in the documentation and I just  
don't understand well enough to see what I could do to "side-step"  
the warnings,

Would you be willing to spend another sentence or two on that?


Sure.  Sorry if I was unclear.

First, I only underlined "protocol" to make sure you looked in the  
right place in the documentation.  The -performSelector:... methods  
are documented as part of the NSObject protocol, not the NSObject  
class.


Second, the documentation for the -performSelector: method says the  
following:


The aSelector argument should identify a method that takes no  
arguments. For methods that return anything other than an object,  
useNSInvocation.


That's saying that the selector you pass to -performSelector: should  
be for a method which takes no arguments and returns an object  
pointer.  This -- the number and types of arguments and return type  
-- is the "signature" of the method.


The -performSelector:withObject: and - 
performSelector:withObject:withObject: methods similarly describe  
the signature requirements for the method identified by the selector  
you pass.


So, if you are working with a selector for a method which matches  
the signature required by one of those methods, then you can safely  
use those methods.  Doing so is a way to invoke the method without  
getting the compiler warning that was troubling you.


Cheers,
Ken



___

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: respondsToSelector - #import OR compiler warnings?

2008-12-30 Thread Steve Cronin

Folks;

This is a clarification for the record
After some sleep and a cup of coffee and I realize that something I  
wrote was hasty, oh OK, sloppy!


I took Bill's quoted example:
@interface NSObject  
(MyClassOptionalMethodsThatMightBeImplementedByJustAboutAnything)

- (void) someSpecial: (Sauce *) aSauce;
- (BOOL) isBobYourUncle: (Child *) aChild;
@end

and morphed it to:

//respondsToSelector silencer - see -myMethodName
@interface NSObject (MyClassName)
- (id) foo;
@end


It now seems to me that while attaching my tweak to the header does in  
fact silence the compiler, it is overly broad -> 'sloppy'.
Why create a category on the entire hierarchy of NSObject?  Why create  
the possibility (albeit remote) of category collision?

A more targeted solution is:

//subclass needs to provide for dynamic handlers
@interface MyClass (RespondsToSelector)
// see also usages of -performSelector()
- (id) foo2:(id)param;
@end

This solution, combined with Ken's proposal to use -performSelector  
for the 'no parameters' cases,  seems to give me a good solution.
(Notice how Bill's example appears to presume this 'easy' use of - 
performSelector()!)

Hope this is useful to someone else...
Steve

NOTE: -performSelector() does have permutations that would make it  
possible to not have the category declaration at all!


___

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: A Mac App & helper NSStatusItem - how to share preferences

2008-12-30 Thread Steve Cronin

Michael - So does the revised code below fix the leak?

After a bit more studying of the documentation, I offer these revised  
'more Cocoa-friendly' updates:


The driving issue is a helper app which wants to access prefs written  
by the 'motherApp'.


- (NSDictionary *) prefDictionary {
CFStringRef appBundleID = (CFStringRef)motherAppBundleID;
	//Core Foundation 'create rule' sez I own this -> I must dispose of  
it  (because 'copy' or 'create' in CF method name)
	CFDictionaryRef prefs = CFPreferencesCopyMultiple(NULL,   
appBundleID,  kCFPreferencesCurrentUser,  kCFPreferencesCurrentHost);

//cast it into an auto-released Cocoa object
	NSDictionary *result = [NSDictionary dictionaryWithDictionary: 
(NSDictionary *)prefs];

//take care of the low-level memory issue
CFRelease(prefs);
return result;
}
It also may be worth pointing out that this dictionary only gets the  
values from the permanent store.
So any registered defaults which the user has never changed do NOT  
show up in this dictionary.


Now instead of using the low-level API to obtain individual values  
simply access key-value pairs using the NSDictionary returned above.
This avoids having to write any further code to read motherApp's  
preferences.
There are some stern words in the docs that weigh against  
indiscriminate accessing using the low-level stuff, so just get the  
dictionary and be done with it!


Now if helper MUST update a motherApp preference:
- (void) setPrefValue:(id)preferenceValue forKey:(NSString  
*)preferenceKey {

CFStringRef appBundleID = (CFStringRef)motherAppBundleID;
	CFPreferencesSetValue((CFStringRef)preferenceKey,   
(CFPropertyListRef)preferenceValue,  appBundleID,   
kCFPreferencesCurrentUser,  kCFPreferencesCurrentHost);	


	// as Jean-Daniel noted the line below is expensive and to be used  
only as required

//that being said - it ain't on the disk until its on the disk
	CFPreferencesSynchronize(appBundleID, kCFPreferencesCurrentUser,  
kCFPreferencesCurrentHost);

}

NOTE: There is a CFPreferencesSetMultiple which allows for setting a  
dictionary's worth of keys at once as well as specifying an array of  
keys to be removed.
You still have to use CSPreferencesSynchronize if you want to get it  
written


I hope this is useful.
Steve

___

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: A Mac App & helper NSStatusItem - how to share preferences

2008-12-30 Thread Steve Cronin

Michael;

OK to really perhaps beat the poor horse,  is the following kosher?

 (NSDictionary *) prefDictionary {
	return [(NSDictionary *)CFPreferencesCopyMultiple(NULL,   
appBundleID,  kCFPreferencesCurrentUser,  kCFPreferencesCurrentHost)  
autorelease];

}

Steve


Michael said:
Yep, this fixes the leak. Your Copy is balanced with a Release and all  
is well.


However, just to be really nitpicky, I'll point out that it's a bit
ugly. You build a new dictionary from the old one, then throw the old
one away. Better to just keep the old one around with something like
this:

return [(id)prefs autorelease];

Or if you're in a garbage collected environment:

return NSMakeCollectable(prefs);

(And you can do both if you're writing dual-mode code.)

___

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


Immediate Nib Loading Error

2009-01-06 Thread Steve Cronin

Folks;

I'm getting an immediate crash, before I can get anything written into  
a log (before any class +iniitialize).

The stack at the crash is below.

In the debugger (XC3.1) I enter 'frame 9' and then do a 'po *(id*)  
($ebp+16)' to see what the offending object is but I just get "No  
symbol "id" in current context."

I must be mis-remembering how to access arguments to the registers...
There are NO non Cocoa objects in the visual display of the  
MainMenu.nib in IB3 (8 - NSCustomObject).


What are all the '??' in this stack? (3-7)  And what are the 2 at the  
lowest level? (16-17)

Any thoughts on how to go about debugging this?

Thanks for any help!,
Steve

#0  0x90347e17 in objc_exception_throw
#1  0x96e90199 in _PFManagedObject_coerceValueForKeyWithDescription
#2  0x96eaa5aa in -[NSManagedObject setPrimitiveValue:forKey:]
#3  0x00094b01 in ??
#4  0x00092666 in ??
#5  0x00091e26 in ??
#6  0x000182f3 in ??
#7  0x784b in ??
#8  0x9270de73 in -[NSCustomObject nibInstantiate]
#9  0x926ee865 in -[NSIBObjectData instantiateObject:]
#10	0x926edf86 in -[NSIBObjectData  
nibInstantiateWithOwner:topLevelObjects:]

#11 0x926e4686 in loadNib
#12	0x926e3fe8 in +[NSBundle(NSNibLoading)  
_loadNibFile:nameTable:withZone:ownerBundle:]
#13	0x926e3c2b in +[NSBundle(NSNibLoading)  
loadNibFile:externalNameTable:withZone:]

#14 0x926e3b69 in +[NSBundle(NSNibLoading) loadNibNamed:owner:]
#15 0x926e3818 in NSApplicationMain
#16 0x227a in ??
#17 0x21a1 in ??

___

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


A Question on estimating +arrayWithCapacity

2009-01-09 Thread Steve Cronin

Folks;

Under some circumstances I'm not sure how big a mutable object might  
need be.

So is there any guidance on coming up with a value for capacity?

Assume for these cases that reasonable guesses range from say 2 -  
5000...


I assume it's wasteful to just do a land grab with +arrayWithCapacity: 
5000
but I also assume that it's unnecessarily burdensome to do  
+arrayWithCapacity:2.


So is the 'best' +arrayWithCapacity:2500?

It feels a little like premature optimization, but I do have to  
provide a value in the code

Thanks for any feedback!
Steve
___

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


iTunes-like tail truncation for attributed strings

2009-01-12 Thread Steve Cronin

Folks;

I have a source list type view.
I am using a tableView not an outlineView because it works for this  
data set.

I have an attributed string which has an image and a name.
This is the only column in this tableView.
This tableView is contained in a splitView which allows this 'nav' to  
be re-sized


A lot of words to describe something quite similar to iTunes.
As you reduce iTunes playlist column size toward its minimum, the  
playlists do a 'tail truncation' on any long text.


How do I achieve that?
What I am seeing regardless of many different settings, is that the  
text 'breaks' at the space between the image and wraps to a a second  
line.

I have Truncate Tail set in the Text Field Cell for the table column.

Can you achieve this with effect with IB and an attributed string or  
is some other code solution necessary?


Thanks for any help!
Steve
___

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: iTunes-like tail truncation for attributed strings

2009-01-12 Thread Steve Cronin

BK;

Thanks!!  Bingo!
The key for me:
"...The behavior can be controlled with -truncatesLastVisibleLine for  
text cells..."   This is a checkbox in IB, at the text cell inside the  
tableColumn.

This in conjunction with the LineBreaks: truncatesTail setting

I did NOT have to make any changes to the attributed string which  
simply specifies an baseline offset and the image  
(attrStringWithAttachement)


God Bless Cocoa!
Steve

On Jan 12, 2009, at 7:08 AM, Buddy Kurz wrote:


I found these in my email archive...


NSString *stringToDraw; // the string to draw
NSMutableDictionary *attrs = [NSMutableDictionary  
dictionaryWithCapacity:2];
NSMutableParagraphStyle *ps = [[[NSMutableParagraphStyle alloc]  
init] autorelease];

[ps setLineBreakMode:NSLineBreakByTruncatingTail];
[attrs setObject:ps forKey:NSParagraphStyleAttributeName];
[stringToDraw drawInRect:rect withAttributes:attrs];



"The Cocoa Text System now allows the last visible line to have an  
ellipsis character appended if the entire content cannot fit into  
the specified bounding box. The behavior can be controlled with - 
truncatesLastVisibleLine for text cells. The -lineBreakMode must be  
either NSLineBreakByWordWrapping or NSLineBreakByCharWrapping for  
this option to take effect.. Also, the  
NSStringDrawingTruncatesLastVisibleLine flag can be specified to  
NSStringDrawing APIs that take NSStringDrawingOptions. The  
NSStringDrawingUsesLineFragmentOrigin flag must also be specified  
for the truncation flag to take effect."


Maybe this will point you in the right direction

bk



On Jan 12, 2009, at 12:19 AM, Steve Cronin wrote:


Folks;

I have a source list type view.
I am using a tableView not an outlineView because it works for this  
data set.

I have an attributed string which has an image and a name.
This is the only column in this tableView.
This tableView is contained in a splitView which allows this 'nav'  
to be re-sized


A lot of words to describe something quite similar to iTunes.
As you reduce iTunes playlist column size toward its minimum, the  
playlists do a 'tail truncation' on any long text.


How do I achieve that?
What I am seeing regardless of many different settings, is that the  
text 'breaks' at the space between the image and wraps to a a  
second line.

I have Truncate Tail set in the Text Field Cell for the table column.

Can you achieve this with effect with IB and an attributed string  
or is some other code solution necessary?


Thanks for any help!
Steve
___

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/buddykurz%40mac.com

This email sent to buddyk...@mac.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


Remove specific items from an Array - is this the best way?

2009-01-13 Thread Steve Cronin

Folks;

I have an array of 'Suspect' objects which have 'names', 'capeSize',  
'hatSize', 'planetOfOrigin',  all the usual stuff...


Now I also have a list of 'RebelOutposts'; a set of 'planet' name  
strings,


What I want to do is remove from a usualSuspects array of Suspects any  
Suspect whose 'planetOfOrigin' is in my  rebelOutpost set.


Here's the wrinkle that makes my brow crinkle:  I really want a  
generic solution that would allow me to remove based on  
'fingerprints', or 


Here's what I'm proposing:

NSSet *workingSet = [NSSet setWithArray:usualSuspects];
NSString *searchOnKey = @"planetOfOrigin"
NSSet *removeMatchingValuesSet = [NSSet setWithSet: rebelOutpost];

offTheHook = [workingSet filteredSetUsingPredicate:[NSPredicate  
predicateWithFormat:@"NOT(%K  IN %@)", searchOnKey,  
removeMatchingValuesSet]];


(Hopefully you can see how this lends itself to wrapping in method  
with 3 parameters)


Is there a gotcha hiding in there? Nulls?
Is there a better way?

Thanks!
Steve



___

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


NSTextView and automaticLinkDetection

2009-01-19 Thread Steve Cronin

Folks;

NSTextView has an attribute 'automaticLinkDetection' that can be set  
in IB or with the usual -set method.
What the docs say is that it "...causes strings representing URLs  
typed in the view to be automatically made into links to those URLs..."
This is what I observe.  If I begin typing in the textView it will  
render a url into a clickable link. This is good!


But what I am looking for is the ability to set a textView's  
stringValue (an NSString) and have any links in the text be reflected  
as links (as if I had typed them in)
So the distinction is that there are no keyboard events to drive this  
evaluation.


I notice that TextEdit does not do this if, for example, you paste a  
plain text snippet which contains a url into a Rich Text document.
The links are not rendered clickable unless you generate a keyboard  
event which causes the url to get evaluated as such...


So is what I am evisioning possible?  I would not know ahead of time  
whether or not the text would contain any, one or many url...


Thanks for any shared knowledge here!
Steve
___

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


Core Data Predicate Builder - comparing dates

2009-08-27 Thread Steve Cronin

Folks;

I have a Core Data entity that has a dateCreated and a dateModified -  
both NSDates in the object files.
I'd like to construct a predicate that will retrieve all records where  
a record's dateModified is greater than that record's dateCreated.


Its deceptively easy to setup something that looks like it should work  
using 'Control-click' and 'Key' in the predicate builder in XCode.

But when I run queries it doesn't appear to yield the right results.
My thinking is that the comparison operators don't properly evaluate  
dates (am I wrong?)


So dropping back to code - how would I write this predicate in code?

Thanks for any help!
Steve

___

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: Core Data Predicate Builder - comparing dates

2009-08-29 Thread Steve Cronin

Ben;

Thanks for taking the time to respond.
I believe that I was blinded by a build issue in my allegation that  
the Predicate Builder mechanism was not giving correct results.

This seems to be working fine now.

I'm glad you have expressed the fragility issue on equivalence - I'll  
remember that.


Thanks for the predicate in code.

It's amazing how often the Cocoa answers are simple and  
straightforward when you finally see them.
I might suggest the predicate you cited be considered for inclusion in  
the Apple documentation somewhere.

Most (all?) the examples use operators and some fixed value.
I know it may seem obvious (it does seem obvious now) but, when you  
don't know, a range of different examples can be a godsend...


Thank-you!
Steve

On Aug 29, 2009, at 7:35 PM, Ben Trumbull wrote:


I have a Core Data entity that has a dateCreated and a dateModified -
both NSDates in the object files.
I'd like to construct a predicate that will retrieve all records  
where

a record's dateModified is greater than that record's dateCreated.

Its deceptively easy to setup something that looks like it should  
work

using 'Control-click' and 'Key' in the predicate builder in XCode.
But when I run queries it doesn't appear to yield the right results.
My thinking is that the comparison operators don't properly evaluate
dates (am I wrong?)


Comparison operators work just fine on dates, although == and != are  
fragile since NSDates are double time stamps, and floating point  
numbers have odd == behavior.


What does the predicate look like ?  How is it not working ?  What  
does SQL logging show ?



So dropping back to code - how would I write this predicate in code?


[NSPredicate predicateWithFormat:@"dateModified > dateCreated"]

- Ben





___

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


XC & IB 3.2 overlapping siblings

2009-09-10 Thread Steve Cronin

Folks;

I know I'm late to the game here but I just took my app for a compile  
under XC3.2 for the first time…


A few NSString encoding loose ends OK  but WHAMO my .xib files are  
hammered with ~100 errors (not warnings!)


".. This view overlaps one of its siblings. Overlapping sibling views  
are not supported on Mac OS X versions prior to 10.5. …"


My base SDK is set to 10.6 and a deployment of 10.4.
Everything was peachy under 10.5 and XC3.1 no such warnings or errors.

Sooo does this mean I cannot use XC3.2 unless I fix all these issues?

Some are buttons that lie on top of each other and are hidden or shown  
based on data.

How does one avoid the overlapping error in this circumstance?
Is there a compiler setting that might be helpful here?

This is certainly not what I expected….

Thanks for all input!
Steve

___

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: XC & IB 3.2 overlapping siblings

2009-09-10 Thread Steve Cronin

Nick;

Hey thanks for the reply!
Yes, I'm aware of the IB target setting.

If you still want to target Tiger this is a BIG surprise that these  
are now treated as errors.


The really big question for me is how do you deal with 2 buttons that  
lie one on top of the other but are never drawn at the same time  
(setHidden)
Do you have to re-jigger everything because IB can't fathom that they  
might not be visible at the same time?
Could you comment on this please - this is a potential real quagmire  
for me…


Steve


On Sep 10, 2009, at 10:15 AM, Nick Zitzmann wrote:



On Sep 10, 2009, at 2:51 AM, Steve Cronin wrote:


My base SDK is set to 10.6 and a deployment of 10.4.
Everything was peachy under 10.5 and XC3.1 no such warnings or  
errors.


Sooo does this mean I cannot use XC3.2 unless I fix all these issues?


Nib deployment targets are actually set in the nibs, not the  
project. If you still want to target Tiger, you should fix the  
errors, since overlapping views are hit-and-miss on Tiger.  
Alternately, if you want to switch to targeting Leopard, then you  
can do it by clicking on the info toolbar button in IB and switching  
the deployment target there.


Nick Zitzmann
<http://www.chronosnet.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


Snow Leopard and Exchange access using ABAddressBook

2009-09-10 Thread Steve Cronin

Folks;

I am trying to understand whether ABAddressBook will permit  
interaction with Exchange.

I don't see anything in the documentation specifically on this point.

Can anyone comment on this?
Am I missing a resource?
Is it currently not supported?

Thanks for any thoughts!
Steve

___

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


Developing a Stand-Alone Service in Snow Leopard

2009-09-13 Thread Steve Cronin

Foks;

I'm trying to develop a stand alone service in Snow Leopard.
The issue I'm running into is how to update the system as I compile a  
new version.
The pbs command shows that the bundle path is the one in my Release  
Build folder


 "pbs -dump_pboard"
{
NSBundleIdentifier = "com.myCompany.myService";
NSBundlePath = "/Volumes/myMacBookPro/Projects/XYZ/Code/ 
build/Release/MyService.service";

NSKeyEquivalent = {
};
NSMenuItem = {
default = MyService;
};
NSMessage = myService;
NSPortName = myServicePort;
NSSendTypes = (
NSStringPboardType,
NSRTFPboardType,
NSTabularTextPboardType
);

So when I recompile I do the following:
1) 'Uncheck' the item in the SysPref/Keyboard/Services list
2) Compile a new version
3) run  "/System/Library/CoreServices/pbs"
4) 'Check' the item in the SysPref/Keyboard/Services list
5) Test the service by using the context menu (which is appearing at  
the right time)


I have convinced myself that the only way to get Snow Leopard to  
recognize the newer version of the service is to log out and back in.

This is tedious.  Is there something I'm missing?

Steve
___

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: Developing a Stand-Alone Service in Snow Leopard

2009-09-13 Thread Steve Cronin

John;

That's good information but I don't see how it helps with a stand- 
alone service  -  how do I (or user) launch the .service bundle?


Steve

On Sep 14, 2009, at 1:12 AM, John C. Randolph wrote:



On Sep 13, 2009, at 10:55 PM, Steve Cronin wrote:

I have convinced myself that the only way to get Snow Leopard to  
recognize the newer version of the service is to log out and back in.

This is tedious.  Is there something I'm missing?


As I recall, each app builds its services menu when it launches.   
Any app launched after you run pbs should show a correctly updated  
services menu.


-jcr



___

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: Developing a Stand-Alone Service in Snow Leopard

2009-09-14 Thread Steve Cronin

Folks

To clarify my initial problem statement:
If I recompile and then issue a "pbs" and then invoke the service it  
continues to execute an earlier instance of the service -- NOT the  
freshly compiled instance….

This is easy to prove

A set of followup questions on STAND-ALONE services

1) How do I programmatically 'check' the service in System Preferences/ 
Keyboard/Services?
I offer the user the option of installing a service.  If they elect to  
install it seems reasonable that they would want the service engaged.

Is the only option to open the System Preferences at the pane?
I offer the new shiny; the user says yeah let's use the new groovy  
stuff;
An then I have to say "sorry I can't figure that out for you -- here's  
a window  here's a whole bunch of scary looking text - give it your  
best shot…

(seems pretty lame to me)

2) Since I offer the option to install, I offer the option to uninstall.
Is it safe to do this?  The .service bundle is marked as open by the  
system.
Is it sufficient to do:   if ([[NSFileManager defaultManager]  
removeFileAtPath:myServicePath handler:self]) NSUpdateDynamicServices();


Thanks for your time and consideration!
Steve


On Sep 14, 2009, at 1:16 AM, Steve Cronin wrote:


John;

That's good information but I don't see how it helps with a stand- 
alone service  -  how do I (or user) launch the .service bundle?


Steve

On Sep 14, 2009, at 1:12 AM, John C. Randolph wrote:



On Sep 13, 2009, at 10:55 PM, Steve Cronin wrote:

I have convinced myself that the only way to get Snow Leopard to  
recognize the newer version of the service is to log out and back  
in.

This is tedious.  Is there something I'm missing?


As I recall, each app builds its services menu when it launches.   
Any app launched after you run pbs should show a correctly updated  
services menu.


-jcr





___

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


Interface Builder .xib deployment/development targets

2009-09-14 Thread Steve Cronin

Folks;

I have an app with a 10.4 Deployment target.

I have recently begun using XC 3.2 and IB 3.2 - spp compiles cleanly  
and all IB 'sibling' issues have been resolved.


I've gotten a field report (release) where I'm seeing:

15:01:38.292 XYZ[11756:20b] HIToolbox: ignoring exception '***
-[NSCFString substringToIndex:]: Range or index out of bounds' that  
raised

inside Carbon event dispatch

This is occurring just as nib is about to open a first window.
I've not seen this before and do not see it on my development machines  
(debug or release)

Reporting machine is MacBookPro5,1 - 10.5.8

I have set the app's IB Deployment Target to 10.4 and IB Development  
Target to IB 3.2


Is there any reason to NOT use IB Development Target of 3.2?

Any thoughts on this?
It "smells" like its coming from IB not from Cocoa class methods…

Steve

___

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: Interface Builder .xib deployment/development targets

2009-09-16 Thread Steve Cronin

Folks;

Got another report today from the field also a MacBookPro5,1 running  
10.5.8
2009-09-16 03:01:53.954 XYZ[329:20b] Error loading /Library/ 
ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/ 
QXPScriptingAdditions: dlopen(/Library/ScriptingAdditions/ 
QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions, 262):  
no suitable image found.  Did find:
	/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/ 
QXPScriptingAdditions: mach-o, but wrong architecture
2009-09-16 03:01:54.150 XYZ[329:20b] HIToolbox: ignoring exception  
'*** -[NSCFString substringToIndex:]: Range or index out of bounds'  
that raised inside Carbon event dispatch


My released app dies immediately afterwards..
What the heck is going on here?
I've compiled the app with XC & IB 3.2 w/ a 10.4 deployment
10.6 SDK (32-bit universal --  i36 ppc ppc7400 ppc970 x86_64)

How I do I hone in on where the problem is??
Steve

On Sep 15, 2009, at 1:50 AM, Graham Cox wrote:



On 15/09/2009, at 4:44 PM, Steve Cronin wrote:


15:01:38.292 XYZ[11756:20b] HIToolbox: ignoring exception '***
-[NSCFString substringToIndex:]: Range or index out of bounds' that  
raised

inside Carbon event dispatch

This is occurring just as nib is about to open a first window.
I've not seen this before and do not see it on my development  
machines (debug or release)

Reporting machine is MacBookPro5,1 - 10.5.8



Is the report coming from a Snow Leopard machine? I've seen a few of  
these running on Snow Leopard. My guess is that previously the  
exception was silently ignored, now it's logging. The exception will  
still be occurring on 10.4/10.5, just not being noticed. So there is  
a bug there that you should probably fix.


--Graham




___

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: Interface Builder .xib deployment/development targets

2009-09-16 Thread Steve Cronin

Jonathan;

Yeah thanks for asking that -  I should have made it clearer.

NO crash report - just program death (hang no response)

The earlier emails include extracts from my own logs that I have the  
users turn on.


Steve

On Sep 16, 2009, at 1:22 PM, Jonathan Hess wrote:



On Sep 16, 2009, at 12:46 AM, Steve Cronin wrote:


Folks;

Got another report today from the field also a MacBookPro5,1  
running 10.5.8
2009-09-16 03:01:53.954 XYZ[329:20b] Error loading /Library/ 
ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/ 
QXPScriptingAdditions: dlopen(/Library/ScriptingAdditions/ 
QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions,  
262): no suitable image found.  Did find:
	/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/ 
MacOS/QXPScriptingAdditions: mach-o, but wrong architecture
2009-09-16 03:01:54.150 XYZ[329:20b] HIToolbox: ignoring exception  
'*** -[NSCFString substringToIndex:]: Range or index out of bounds'  
that raised inside Carbon event dispatch


My released app dies immediately afterwards..
What the heck is going on here?
I've compiled the app with XC & IB 3.2 w/ a 10.4 deployment
10.6 SDK (32-bit universal --  i36 ppc ppc7400 ppc970 x86_64)

How I do I hone in on where the problem is??


Do you have a crash report? If so, does it have a backtrace of where  
the exception occurred?


Jon Hess


Steve

On Sep 15, 2009, at 1:50 AM, Graham Cox wrote:



On 15/09/2009, at 4:44 PM, Steve Cronin wrote:


15:01:38.292 XYZ[11756:20b] HIToolbox: ignoring exception '***
-[NSCFString substringToIndex:]: Range or index out of bounds'  
that raised

inside Carbon event dispatch

This is occurring just as nib is about to open a first window.
I've not seen this before and do not see it on my development  
machines (debug or release)

Reporting machine is MacBookPro5,1 - 10.5.8



Is the report coming from a Snow Leopard machine? I've seen a few  
of these running on Snow Leopard. My guess is that previously the  
exception was silently ignored, now it's logging. The exception  
will still be occurring on 10.4/10.5, just not being noticed. So  
there is a bug there that you should probably fix.


--Graham




___

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/jhess%40apple.com

This email sent to jh...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Static Analyzer and Core Foundation

2009-09-18 Thread Steve Cronin

Folks;

Alert - potential boneheaded-ness lies ahead - please be gentle.

I'll be the first to admit that I'm much happier in ObjC than C…

I thought I would try static analysis and see what turned up.
On the whole I must say I'm pleased but this one has me questioning my  
basic understanding


if (![[NSFileManager defaultManager] fileExistsAtPath:thisPath]) {
…
41  } else {
42  MDItemRef mdi = MDItemCreate( nil, (CFStringRef)thisPath );
43  if  ( mdi != nil )  {
44			CFDictionaryRef dictRef = MDItemCopyAttributes( mdi,  
MDItemCopyAttributeNames(mdi));

…
CFRelease(dictRef);
} else {
… handle error
}
}

Static Analysis tells me I have a potential leak of object allocated  
on line 44 -- that's all.


My questions are:
1) Why is there not a warning for the object allocated on line 42 -  
mdi ?

2) Why is the CFRelease(dictRef) not sufficient?

Thank you for you patience!
Steve___

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: Static Analyzer and Core Foundation

2009-09-18 Thread Steve Cronin

Luke;

OK thank-you for that answer to question 2!
Any thoughts on question 1?

Steve

On Sep 18, 2009, at 6:36 PM, Luke the Hiesterman wrote:

Line 44 creates 2 objects, one goes into the dictRef, the other is  
not assigned to a variable, but is used only as the second argument  
to MDItemCopyAttributes. The object that you create inside that call  
is never released.


Luke

On Sep 18, 2009, at 4:33 PM, Steve Cronin wrote:


Folks;

Alert - potential boneheaded-ness lies ahead - please be gentle.

I'll be the first to admit that I'm much happier in ObjC than C…

I thought I would try static analysis and see what turned up.
On the whole I must say I'm pleased but this one has me questioning  
my basic understanding


if (![[NSFileManager defaultManager] fileExistsAtPath:thisPath]) {
…
41  } else {
42  MDItemRef mdi = MDItemCreate( nil, (CFStringRef)thisPath );
43  if  ( mdi != nil )  {
44			CFDictionaryRef dictRef = MDItemCopyAttributes( mdi,  
MDItemCopyAttributeNames(mdi));

…
CFRelease(dictRef);
} else {
… handle error
}
}

Static Analysis tells me I have a potential leak of object  
allocated on line 44 -- that's all.


My questions are:
1) Why is there not a warning for the object allocated on line 42 -  
mdi ?

2) Why is the CFRelease(dictRef) not sufficient?

Thank you for you patience!
Steve___

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/luketheh%40apple.com

This email sent to luket...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Static Analyzer and Core Foundation

2009-09-18 Thread Steve Cronin

Luke;

I've adapted the code to accomodate your's and Chris' answer to  
question 2.


Here's the entire method, which now shows not static analyzer issues  
but I still would like to understand why not.


+ (NSDictionary *)metadataForFilePath:(NSString *)thisPath {
NSDictionary *md = [NSDictionary dictionary];
if (![[NSFileManager defaultManager] fileExistsAtPath:thisPath]) {
NSLog(@"file does not existl");
} else {
MDItemRef mdi = MDItemCreate( nil, (CFStringRef)thisPath );
if  ( mdi != nil )  {
CFArrayRef arrayRef = MDItemCopyAttributeNames(mdi);
CFDictionaryRef dictRef = MDItemCopyAttributes( mdi, 
arrayRef);
md = [NSDictionary 
dictionaryWithDictionary:(NSDictionary *)dictRef];
CFRelease(dictRef);
CFRelease(arrayRef);
} else {
NSLog(@"mdi is nil");
}
}
return md;
}

Is this the 'best' this can be?
Thanks for helping me learn,
Steve

On Sep 18, 2009, at 6:44 PM, Luke the Hiesterman wrote:


There's not enough code here to give a good answer to question 1.


___

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

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

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

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


MutableDictionary setValue:forKeyPath - strange behavior

2009-09-20 Thread Steve Cronin

Folks;

I have recently converted to XC & IB 3.2
I've updated my project to be a 3.2 project using a baseSDK of 10.6  
with deployment target of 10.4


I've run the static analyzer and have no analyzer issues as well as no  
compiler nor IB warnings
I'm feeling good about this but now code that worked under Leopard is  
no longer working.


I have an instance variable which is an NSMutableDictionary  *  
myBaseSettings
 I run a method which steps thru the keys in a local NSDictionary  
(sessionSettings) to possibly set some values into myBaseSettings


NSDictionary * sessionSettings = ...;
NSArray *values, *keys = [sessionSettings allKeys];
int dictCount = [keys count];
if (dictCount>0) {
values = [sessionSettings allValues];
NSString *thisKey, *thisValue;
for (i=0 ; i(NOTE: I use setValue:forKePath because the sessionSetting keys can be  
dictionaries)


I get an exceptions thrown whenever thisKey is a normal 'key' (ie  
"workPhone") but NOT when thisKey is a 'keyPath' (ie.  
"nameDict.firstName")
'*** -[NSCFDictionary setObject:forKey:]: mutating method sent to  
immutable object'

The key and value are both valid strings (verified using 'po' gdb)

It seems like somehow the instance variable is not being treated as an  
NSMutableDictionary but why?


Thanks for any thoughts on this - I'm baffled!
Steve
___

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: MutableDictionary setValue:forKeyPath - strange behavior

2009-09-20 Thread Steve Cronin

Kyle;

Thanks for such a speedy response.  (and on a Sunday afternoon too!)

That code is a fairly complex set of interlocking methods.
Why would the construction of this NSMutableDictionary have anything  
to do with this error?


Steve

On Sep 20, 2009, at 1:51 PM, Kyle Sluder wrote:

On Sep 20, 2009, at 11:35 AM, Steve Cronin   
wrote:


I have an instance variable which is an NSMutableDictionary  *  
myBaseSettings


You need to post the code that creates this dictionary.

--Kyle Sluder


___

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: MutableDictionary setValue:forKeyPath - strange behavior

2009-09-20 Thread Steve Cronin

Kyle;

In order to answer your request, I've gone back through the code that  
generates myBaseSettings

essentially it is:

	NSMutableDictionary *localDict = [NSMutableDictionary  
dictionaryWithCapacity:70];
	[localDict setObject:[self generateInterestingValue1]  
forKey:@"interestingKey"];

…
…
[self setMyBaseSettings:localDict];

where setMyBaseSettings is an old-school KVC setter method

- (void) ssetMyBaseSettings:(NSMutableDictionary *) newSettings {
if (myBaseSettings!= newSettings) {
[myBaseSettings release];
myBaseSettings = [newSettings retain];
}
}

Does this provide you the information you are looking for?

Steve


On Sep 20, 2009, at 1:51 PM, Kyle Sluder wrote:

On Sep 20, 2009, at 11:35 AM, Steve Cronin   
wrote:


I have an instance variable which is an NSMutableDictionary  *  
myBaseSettings


You need to post the code that creates this dictionary.

--Kyle Sluder


___

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: MutableDictionary setValue:forKeyPath - strange behavior

2009-09-20 Thread Steve Cronin

Folks;

Thanks for all of the guidance!  I have found the issue.

It turns out that [localDict copy] is what was being sent to the  
setBaseSetting.


In dealing with the static analyzer's warnings I must have made this  
change and then had failed to back it out…

MY BAD
Removed this and all is well again.

A tip of the hat to Kyle for immediately sending me in the right  
direction.


Karl - darn fine point about the random nature of 'allKeys'
	(this code has been working fine for months - but I will stop relying  
on this 'side-effect')


Thank-you all
Steve



On Sep 20, 2009, at 5:01 PM, Kyle Sluder wrote:


On Sun, Sep 20, 2009 at 12:42 PM, Steve Cronin  
 wrote:

essentially it is:


"Essentially" isn't good enough; actual copy-paste is necessary to
ensure you're doing it correctly.


   NSMutableDictionary *localDict = [NSMutableDictionary
dictionaryWithCapacity:70];


This is good.


- (void) ssetMyBaseSettings:(NSMutableDictionary *) newSettings {


There's an extra "s" in here… does this mean you didn't actually
copy/paste the setter from your code?  Or maybe you're using a
synthesized @property(copy) getter but a manually implemented setter,
and because you have typo'd the setter method, the compiler is
synthesizing one for you instead?

--Kyle Sluder


___

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


Data Model Versions and -fetchRequestTemplateForName

2009-09-20 Thread Steve Cronin

Folks;

I have recently converted to XC & IB 3.2
I've updated my project to be a 3.2 project using a baseSDK of 10.6  
with deployment target of 10.4


I have a Core Data model that I've been very happy with starting in  
10.4 and continuing in 10.5..
In readying for the brave new world ahead I have added a 'version' to  
the data model.
I see 2 xcdatamodel documents (app1 and app2) - they are the same at  
this point


After bring the app up to the tools and project setting described  
above I've begun testing the release product on Tiger, Leopard , and  
Snow Leopard.


The following method worked fine on all 3 OSes before these changes

- (NSArray *) elementsByTemplate:(NSString *) templateName {
NSError *error = nil;
NSArray *results;
//moc is an instance variable for the managedObectContext
	NSFetchRequest * fReq = [[[moc persistentStoreCoordinator]  
managedObjectModel] fetchRequestTemplateForName:templateName];

@try { results = [moc executeFetchRequest:fReq error:&error]; }
	@catch ( NSException *e ) { NSLog(@"(Template:%@) Caught %@: %@ \r  
%@", templateName, [e name], [e  reason], [e  userInfo]); }
	if ( error != nil) { NSLog(@"%@ - Caught %i: %@  info = %@",  
NSStringFromSelector(_cmd), [error code], [error  domain], [error  
userInfo]); }

return ( (results==nil) ? [NSArray array] : results);
}

This fails on Tiger BUT continues to work normally on Leopard & Snow  
Leopard.

fReg is NULL  on Tiger (used to work fine on Tiger)
so the exception get caught with 'fetch request must have an entity)
[Yeah - so I do see that I should test for a null fetchRequest but  
that's not the issue really!]


Is the model versioning the problem?  Can I 'undo' that?
(I can't do a 'fetchRequestTemplatesByName' because that was  
introduced in 10.5)

Is there something I can do or that I am overlooking?

I have backed the base SDK down to 10.5 (I can easily because I just  
made that change to 10.6 and have no embedded 10.6 code as yet)

It still fails for Tiger.

I have also removed app2 from the xcdatamodeld bundle but this also  
does not change the result.


I'm stumped on what to do to remedy this situation!

Thoughts?
Steve


___

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 Crashing on a second AppleScript call

2009-09-25 Thread Steve Cronin

Folks;

I have an app that receives AppleScript calls

App passes Clang with no warnings; using XC 3.2 w/ 10.6SDK

The call is made successfully and performs beautifully -- the first  
time!

Everything works just as intended.

The second script call is processed by the app but crashes immediately  
after it finishes processing.


Here's the stack:
#0  0x9330692c in objc_msgSend
#1  0x00628d30 in ??
#2  0x93ae75bd in _CFAutoreleasePoolPop
#3  0x94562e62 in NSPopAutoreleasePool
#4  0x94562d8a in -[NSAutoreleasePool drain]
#5  0x945aa25e in _NSAppleEventManagerGenericHandler
#6  0x943bbde6 in aeDispatchAppleEvent
#7  0x943bbce5 in dispatchEventAndSendReply
#8  0x943bbbf2 in aeProcessAppleEvent
#9  0x920de381 in AEProcessAppleEvent
#10 0x911caed2 in _DPSNextEvent
#11	0x911ca50a in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:]

#12 0x9118c69b in -[NSApplication run]
#13 0x91184735 in NSApplicationMain

Any thoughts on what I am doing wrong? or how to track down what is  
going on?


Thanks for your time and consideration,
Steve





___

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


Static Analyzer Question

2009-09-29 Thread Steve Cronin

Folks;

I have a Clang issue that is making me a little crazy.

I have a modestly complex Core Data application with several thousand  
lines of code.

I've run Clang and at this point I have only one issue:

"…. Object with +0 retain counts returned to caller where a +1  
(owning) retain count is expected"

this is shown at the end of a particular method.

The deal is that, over time, I have isolated this method and at this  
moment there are NO methods which call it.
I cannot leave it like this - this isolation is a result of honing in  
on the Clang issue...


A very common pattern for my application looks like this:

+ (NSString *) fooBar {
NSString *result = @"";
…..
if (x) {
result = @"1";
...
} else {
result = @"2";
}
return result;
}

Yes this is a class method - I use this pattern for both class and  
instance methods.


This is the only method that Clang has an issue with…

Why does Clang believe that an 'owning retain count is expected' if  
the method is never called?
Why is Clang picking on this one method which mirrors the mechanics of  
so many others?


Any thoughts appreciated!
Steve


___

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: Static Analyzer Question

2009-09-29 Thread Steve Cronin

Gentlemen;

YES Bingo!   + newWidgetID

I love how Cocoa can so drive you crazy and then when insight happens  
it's often nearly painful in its elegance and simplicity…

Breathtaking sometimes….

Thank-you all,
Steve



On Sep 29, 2009, at 5:12 PM, Steve Cronin wrote:

"…. Object with +0 retain counts returned to caller where a +1  
(owning) retain count is expected"

this is shown at the end of a particular method.


I think this means the method has a name that by convention  
indicates that it returns a reference the caller must release — i.e.  
a prefix of "alloc" or "copy" or "mutableCopy"



+ (NSString *) fooBar {
NSString *result = @"";
…..
if (x) {
result = @"1";
...
} else {
result = @"2";
}
return result;
}


What's the actual name (not 'fooBar')?

Why does Clang believe that an 'owning retain count is expected' if  
the method is never called?


Objective-C is a dynamic enough language that there is no way to  
tell at compile time whether a method is reachable or not. Even if  
that selector never appears in your code, it could be constructed at  
runtime, or your code could load a plugin bundle that calls that  
selector.


—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


Nib Loading Crash on Tiger only

2009-09-29 Thread Steve Cronin

Folks;

I have converted to using SL; XC3.2; IB 3.2.
I have an app with a deployment target of 10.4
There are no IB warnings; the dev target is IB 3.2

Things have been working reasonably well but now when I test on a  
Tiger I crash immediately

Leopard and Snow Leopard are fine

2009-09-30 01:34:18.529 XYZ[8852] An uncaught exception was raised
2009-09-30 01:34:18.530 XYZ[8852] *** -[NSKeyedUnarchiver  
decodeObjectForKey:]: cannot decode object of class (NSCoreUIImageRep)
2009-09-30 01:34:18.530 XYZ[8852] *** Uncaught exception:  
 *** -[NSKeyedUnarchiver  
decodeObjectForKey:]: cannot decode object of class (NSCoreUIImageRep)


I'm using .xib files but I don't what I should even be looking for.

What is this trying to tell me?
Steve
___

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: Nib Loading Crash on Tiger only

2009-09-30 Thread Steve Cronin

Kyle * Graham;

The IB Info says:
Deployment Target: 10.4
Development Target: IB 3.2

There are no error or warnings!

What should I be looking at?
Steve



On Sep 30, 2009, at 1:56 AM, Kyle Sluder wrote:


Check your IB compatibility settings.  Looks like you've archived an
image into your nib that doesn't exist on Tiger.

--Kyle Sluder


___

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: Nib Loading Crash on Tiger only -- SOLVED (well made gone...)

2009-09-30 Thread Steve Cronin

Folks;

I opened the .xib file in a text editor -searched for 'NSCoreUIImageRep'

I found one instance (thankfully) and by 'reading' the text was able  
to determine that it was a matrix of 2 radio buttons.


I removed the offending matrix and re-instantiated a fresh one.
I monitored the .xib text as I re-sized it but was unable to generate  
a 'NSCoreUIImageRep' again.

Compiled - deployed to Tiger -> works fine….

I dunno, my gut tells me that there is some way thru resize and cell  
spacing that IB 3.2 will use a 'NSCoreUIImageRep' but I gotta move on…

Never was any IB warnings or errors….

Maybe this will help someone else…

Thanks Graham and Kyle for the assist,
Steve


On Sep 30, 2009, at 1:56 AM, Kyle Sluder wrote:


Check your IB compatibility settings.  Looks like you've archived an
image into your nib that doesn't exist on Tiger.

--Kyle Sluder




___

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


rangeOfString & UTF8

2009-10-04 Thread Steve Cronin

Folks;

 (thePhrase) :  Geschäftsführer (CEO):

 (tString):  Geschäftsführer (CEO)

Both
	curPos = [thePhrase rangeOfString: tString  
options:NSCaseInsensitiveSearch].location;


AND

	NSLocale *tLocale = [[[NSLocale alloc]  
initWithLocaleIdentifier:@"de_DE"] autorelease];
	curPos = [thePhrase rangeOfString: tString  
options:NSCaseInsensitiveSearch range:NSMakeRange(0, [thePhrase  
length]) locale:tLocale].location;


yield curPos == NSNotFound

Here's some printout from the console:
Printing description of thePhrase:
Gesch\u00e4ftsf\u00fchrer (CEO):

Printing description of tString:
Gesch\u00e4ftsf\u00fchrer (CEO)

What am I not understanding here?
Steve___

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: rangeOfString & UTF8 - SOLVED

2009-10-04 Thread Steve Cronin

Clark;

OK thanks for the whack on the head…

I had managed to convince myself that there was something about the  
utf8 umlats and all that I wasn't understanding …


No the problem was simply that there was a trailing space at the end  
of tString -> 'Geschäftsführer (CEO) '


Thanks for your time!
Steve

On Oct 4, 2009, at 4:17 PM, Clark Cox wrote:

On Sun, Oct 4, 2009 at 1:48 PM, Steve Cronin   
wrote:

Folks;

 (thePhrase) :  Geschäftsführer (CEO):

 (tString):  Geschäftsführer (CEO)

Both
   curPos = [thePhrase rangeOfString: tString
options:NSCaseInsensitiveSearch].location;

AND

   NSLocale *tLocale = [[[NSLocale alloc]
initWithLocaleIdentifier:@"de_DE"] autorelease];
   curPos = [thePhrase rangeOfString: tString
options:NSCaseInsensitiveSearch range:NSMakeRange(0, [thePhrase  
length])

locale:tLocale].location;

yield curPos == NSNotFound

Here's some printout from the console:
Printing description of thePhrase:
Gesch\u00e4ftsf\u00fchrer (CEO):

Printing description of tString:
Gesch\u00e4ftsf\u00fchrer (CEO)

What am I not understanding here?


Something else must be going on. I've just tried to replicate your
situation, and had no problems:

[c...@ccox-shiny:~]% cat test.m
#import 


int main() {
   NSString*thePhrase  = @"Geschäftsführer (CEO):";
   NSString*tString= @"Geschäftsführer (CEO)";

   NSRange range   = [thePhrase rangeOfString: tString
options: NSCaseInsensitiveSearch];

   NSLog(@"thePhrase   = \"%...@\"", thePhrase);
   NSLog(@"tString = \"%...@\"", tString);
   NSLog(@"range   = %@", NSStringFromRange(range));

   return 0;
}
[c...@ccox-shiny:~]% cc test.m -framework Foundation -fobjc-gc && ./ 
a.out
2009-10-04 14:17:04.981 a.out[7705:903] thePhrase   =  
"Geschäftsführer (CEO):"
2009-10-04 14:17:04.983 a.out[7705:903] tString =  
"Geschäftsführer (CEO)"

2009-10-04 14:17:04.983 a.out[7705:903] range   = {0, 21}




--
Clark S. Cox III
clarkc...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Coding around a known bug

2008-08-02 Thread Steve Cronin

Folks:

I'm looking for some advice on how to code around a Leopard bug
(radar 5905139  & 5599887).

Leopard broke the following:
		OSStatus returnCode = TransformProcessType(&psn,  
kProcessTransformToForegroundApplication);


TransformProcessType used to bring a background app to the foreground,  
which it still does EXCEPT for the fact that the menubar does not get  
correctly established until the user first brings another app to the  
foreground and then re-establishes the 'wounded' app as the  
foreground.  Once this 'app toggling' is done, all is well.


So I can trap Tiger v. Leopard and do toggling only on Leopard, that's  
pretty straight-forward.


What I'm looking for is best advice on how to get the menubar to be  
'right' in code.


I've tried: 
[[NSWorkspace sharedWorkspace] launchApplication:@"Finder"];
followed by an Applescript to 'activate' myself.
OK it works, but it jarring to have the 'Finder' just suddenly jump  
into view and I'm quite sure customers will NOT like it.

Any thoughts?

Also any thoughts on how possibly to code this so that when, or if,  
Apple ever fixes TransformProcessType that the fix might right itself  
and not require a new version.


Thanks,
Steve

 
___


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: Coding around a known bug

2008-08-02 Thread Steve Cronin

Charles;

Because I need to convert the app from a background (LSUIElement=1)  
application.

I am not aware of an AppleScript way to do that.
If there is one, can you share a pointer?

Thanks for your time!
Steve

On Aug 2, 2008, at 1:40 PM, Charles Srstka wrote:


On Aug 2, 2008, at 11:40 AM, Steve Cronin wrote:


Folks:

I'm looking for some advice on how to code around a Leopard bug
(radar 5905139  & 5599887).

Leopard broke the following:
		OSStatus returnCode = TransformProcessType(&psn,  
kProcessTransformToForegroundApplication);


TransformProcessType used to bring a background app to the  
foreground, which it still does EXCEPT for the fact that the  
menubar does not get correctly established until the user first  
brings another app to the foreground and then re-establishes the  
'wounded' app as the foreground.  Once this 'app toggling' is done,  
all is well.


So I can trap Tiger v. Leopard and do toggling only on Leopard,  
that's pretty straight-forward.


What I'm looking for is best advice on how to get the menubar to be  
'right' in code.


I've tried: 
[[NSWorkspace sharedWorkspace] launchApplication:@"Finder"];
followed by an Applescript to 'activate' myself.
OK it works, but it jarring to have the 'Finder' just suddenly jump  
into view and I'm quite sure customers will NOT like it.

Any thoughts?

Also any thoughts on how possibly to code this so that when, or if,  
Apple ever fixes TransformProcessType that the fix might right  
itself and not require a new version.


Why not just use the AppleScript to bring your app to the foreground  
in the first place, instead of TransformProcessType?


Charles


___

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]


Launch Path Not Accessible

2008-08-02 Thread Steve Cronin

Folks;

I'm trying to do something that seems like it should be easy, but I'm  
stymied by what I think is a permissions error I don't understand.


I'm trying to run a script using NSTask.
I have the static script stored as a separate file in my bundle.
I have created a folder in my "Applications Support" directory called  
"Scripts" and copied my script and several items into this directory.

Note that this has a space in the full pathname!

SO I have tried the following:
NSString *myScriptPath = [[self scriptsFolderPath]  
stringByAppendingPathComponent:@"myUseful.script"];  //yes I have  
verified this is a valid path!!!

NSTask *task = [[[NSTask alloc] init] autorelease];
[task setLaunchPath: myScriptPath];
[task setArguments:[NSArray arrayWithObject:...]];
[task setStandardInput:[NSPipe pipe]];
[task launch];

ERRROR: launch path not accessible

So, thinking that the 'space' maybe wanking out the 'setLaunchPath' I  
tried to convert to a 'safe' url path:

NSURL *myScriptFileURL = [NSURL fileURLWithPath:t];
...
[task setLaunchPath:[myScriptFileURL absoluteString]];

Same error!

The docs don't make it clear TO ME why I would need special  
permissions to launch a script in my own "App Support" directory.

Am I out in the weeds chasing the wrong rabbits?

Any guidance appreciated!
Steve



___

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: Launch Path Not Accessible

2008-08-02 Thread Steve Cronin

Andrew:

Thanks for the slap on the head!
So I chmod'ed the file and no longer get the 'not accessible error'   
YEAH!


BUT now I get:
*** NSTask: Task create for path '/Users/steve/Library/Application  
Support/XYZ/Scripts/myUseful.o' failed: 88, "Malformed Mach-o file"


So I must be missing something about the contents of script files.
Here's my script:

myUseful.m
#import 
int main(int argc, char **argv)
{
char dummy;
read(STDIN_FILENO, &dummy, 1);
[NSAutoreleasePool new];
	NSURL *url = [NSURL fileURLWithPath:[NSString  
stringWithUTF8String:argv[1]]];

LSOpenCFURLRef((CFURLRef)url, NULL);
return 0;
}

You will just have to trust me that I DO need to launch the file in  
this manner.

What do I need to do to this file to make it into the correct format?

THANKS AGAIN for the chmod help!
Steve

On Aug 2, 2008, at 3:26 PM, Andrew Farmer wrote:


On 02 Aug 08, at 13:01, Steve Cronin wrote:
I'm trying to do something that seems like it should be easy, but  
I'm stymied by what I think is a permissions error I don't  
understand.


I'm trying to run a script using NSTask.
I have the static script stored as a separate file in my bundle.
I have created a folder in my "Applications Support" directory  
called "Scripts" and copied my script and several items into this  
directory.

Note that this has a space in the full pathname!

SO I have tried the following:
NSString *myScriptPath = [[self scriptsFolderPath]  
stringByAppendingPathComponent:@"myUseful.script"];  //yes I have  
verified this is a valid path!!!

NSTask *task = [[[NSTask alloc] init] autorelease];
[task setLaunchPath: myScriptPath];
[task setArguments:[NSArray arrayWithObject:...]];
[task setStandardInput:[NSPipe pipe]];
[task launch];

ERRROR: launch path not accessible


Are you sure myUseful.script is directly executable? Just because  
it's double-clickable in the Finder doesn't mean it's executable...  
if this is an AppleScript, though, you may have better luck working  
with NSAppleScript.


So, thinking that the 'space' maybe wanking out the 'setLaunchPath'  
I tried to convert to a 'safe' url path:

NSURL *myScriptFileURL = [NSURL fileURLWithPath:t];
...
[task setLaunchPath:[myScriptFileURL absoluteString]];


Nope. NSTask takes a filesystem path, not a URL.


___

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: Coding around a known bug - SOLVED (acceptably)

2008-08-02 Thread Steve Cronin

Andrew & Aaron

Yes I have read the discussion in the docs related to  
TransformProcessType().  My bad - here's a more complete snippet:


if (...some condition..) {
ProcessSerialNumber psn = { 0, kCurrentProcess };
		OSStatus returnCode = TransformProcessType(&psn,  
kProcessTransformToForegroundApplication);

if( returnCode == 0) { SetFrontProcess(&psn); }
}

The result of this is that an icon does appear in the dock BUT the  
menubar is NOT shown until the application toggling business I  
described in the initial email occurs.


I've also tried all Aaron's various suggestions related to NSMenu, and  
NSApplication all with the same result.
Seems to me TransformProcessType(&psn,  
kProcessTransformToForegroundApplication) leaves the transformed  
process in a strange state; a state not expected by NSApplication.


So here's what I've finally gotten to as an acceptable solution.
This flashes the menubar but otherwise the context switch is as  
expected - no unexpected app jumps to front.
(AppleScriptTool is a custom object which has various convenience  
methods I've developed)


	NSString *currentApp = [AppleScriptTool stringFromAppleScript:@"tell  
application \"System Events\" to name of first process whose frontmost  
is true"];

ProcessSerialNumber psn = { 0, kCurrentProcess };
	OSStatus returnCode = TransformProcessType(&psn,  
kProcessTransformToForegroundApplication);

if( returnCode == 0) {
		[[NSWorkspace sharedWorkspace] launchApplication:currentApp];  // 
this step is necessary - if left out the menubar is not updated
		[AppleScriptTool  
bringApplicationToFront:myAppName]; //uses @"tell  
application \"[EMAIL PROTECTED]" to activate"  [NOTE: SetFrontProcess() doesn't work]

}

I cannot use NSWorkspace's -activeApplication in the first line  
because it sees the calling app as the active app...


It also seems to me that when (if) Apple does fix  
TransformProcessType(), since the call to SetFrontProcess() is spelled  
out as necessary, that my solution will not break nor result in  
undesired behavior.


Maybe someone else will find this useful...

Thanks to all,
Steve


On Aug 2, 2008, at 6:11 PM, Andrew Merenbach wrote:


On Aug 2, 2008, at 9:40 AM, Steve Cronin wrote:


Folks:

I'm looking for some advice on how to code around a Leopard bug
(radar 5905139  & 5599887).

Leopard broke the following:
		OSStatus returnCode = TransformProcessType(&psn,  
kProcessTransformToForegroundApplication);


TransformProcessType used to bring a background app to the  
foreground, which it still does EXCEPT for the fact that the  
menubar does not get correctly established until the user first  
brings another app to the foreground and then re-establishes the  
'wounded' app as the foreground.  Once this 'app toggling' is done,  
all is well.


So I can trap Tiger v. Leopard and do toggling only on Leopard,  
that's pretty straight-forward.


What I'm looking for is best advice on how to get the menubar to be  
'right' in code.


I've tried: 
[[NSWorkspace sharedWorkspace] launchApplication:@"Finder"];
followed by an Applescript to 'activate' myself.
OK it works, but it jarring to have the 'Finder' just suddenly jump  
into view and I'm quite sure customers will NOT like it.

Any thoughts?

Also any thoughts on how possibly to code this so that when, or if,  
Apple ever fixes TransformProcessType that the fix might right  
itself and not require a new version.


Thanks,
Steve


Hi, Steve,

The docs appear to mention something that may be of use -- see the  
Discussion for TransformProcessType():


You can use this call to transform a background-only application  
into a foreground application. A foreground application appears in  
the Dock (and in the Force Quit dialog) and contains a menu bar.  
This function does not cause the application to be brought to the  
front; you must call SetFrontProcess to do so.



Apologies if you are already, but -- are you calling  
SetFrontProcess()?


Cheers,
Andrew



___

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]


Restarting an app -- AppleScript 'launch' in a detached shell

2008-08-03 Thread Steve Cronin

Folks;

I am trying to simply restart my app.  To my dismay, I cannot find a  
way to do this in Cocoa.

Please enlighten me if I have failed to understand something!!

After perusing the archives, what makes the most sense to me is to  
launch a detached shell that executes a simple AppleScript.

The script has a delay of 2 seconds and then simply does a 'launch'.

I've got the script working like a champ in a straight terminal session:
> /usr/bin/osascript '/Users/steve/Desktop/Restart.script'

So now:
NSString *cmdString = [NSString stringWithFormat:@"/usr/bin/osascript  
'%@'",[[self scriptsFolderPath  
stringByAppendingPathComponent:@"Restart.script"]];

NSTask *task = [[[NSTask alloc] init] autorelease];
[task setLaunchPath:@"/bin/sh"];
[task setArguments:[NSArray arrayWithObjects:@"-c", cmdString, @" &",  
nil]];  		//the '&' detaches the shell, yes?
[task setStandardError:[NSFileHandle  
fileHandleForWritingAtPath:errorOutPath]];
[task waitUntilExit];	// <--  I've also tried [task  
launch] but the same result.

[[NSApplication sharedApplication] terminate:self];

This unsurprisingly DOES quit the application but the script doesn't  
appear to execute, nothing further happens...

Am I not using the argument list correctly?
I also do not see anything at all in the file @ errorOutPath  nor  do  
I don't see any console messages.

How could I pick up any data on what IS happening?

I know I am missing something here but I AM puzzled...

Thanks for any help!
Steve
___

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: Restarting an app -- AppleScript 'launch' in a detached shell

2008-08-03 Thread Steve Cronin

Andrew;

OK for the sake of the group I will parade my ignorance so that  
perhaps others can learn too...


First I do understand your point that using AppleScript is using an  
unnecessary high-level tool when a lower-level tool will do!
Thanks for keeping me on-point there!!  Good old-school unix thinking  
- always a good thing.


I have 4 questions
1) Given that it is higher-level than necessary, I would still  
appreciate understanding why it doesn't work.
I revamped the '&' and added it to the end of the osaxscript command  
instead of passing as argument -> no change..


2) In the script you cited, I don't understand the 'if(fork() ||  
fork())' conditional test.  Can you clarify this statement?


3) Why are you using 'execl' and not 'exec'?

4) When you say "...launch this with a single argument..."  I' not  
sure of exactly what you mean.  Launch how?
I tried creating a text file with your script as the contents  
(Restart.unixscript)


		//enclose the paths in single quotes because there are potentially  
spaces in either path (eg 'Application Support')
		NSString *scriptPath = [NSString stringWithFormat:@"'%@'",[[self  
scriptsFolderPath]  
stringByAppendingPathComponent:@"Restart.unixscript"]];
		NSString *myPath = [NSString stringWithFormat:@"'%@'",[[NSBundle  
mainBundle] bundlePath]];
		NSFileHandle *stdErrors = [NSFileHandle  
fileHandleForWritingAtPath:@"/Users/steve/Desktop/RestartErrors.txt"];

NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/bin/sh"];
		[task setArguments:[NSArray arrayWithObjects:scriptPath, myPath,  
nil]];  // no -c means that first parameter is file of commands

[task setStandardError:stdErrors];
[task setStandardOutput:stdErrors];
[task launch];
[[NSApplication sharedApplication] terminate:self];

When I do this I get the following in stdErrors:
/bin/sh: '/Users/steve/Library/Application Support/XYZ/Scripts/ 
Restart.unixscript': No such file or directory


NOTE: enlosing in double quote doesn't change the result; nor  
obviously does not enclosing the paths in a delimiter at all

Seems like I'm missing something

Thank-you for your patience on this!
Steve

On Aug 3, 2008, at 4:12 PM, Andrew Farmer wrote:


On 03 Aug 08, at 14:00, Steve Cronin wrote:
I am trying to simply restart my app.  To my dismay, I cannot find  
a way to do this in Cocoa.

Please enlighten me if I have failed to understand something!!

After perusing the archives, what makes the most sense to me is to  
launch a detached shell that executes a simple AppleScript.

The script has a delay of 2 seconds and then simply does a 'launch'.


You're overcomplicating things.

int main(int argc, char **argv) {
if(fork() || fork()) exit(0);
sleep(2);
execl(argv[1], argv[1], NULL);
exit(1);
}

Launch this with a single argument - the path to your application's  
executable. It'll background itself, sleep two seconds, and exec  
your application.


(Standard disclaimer: typed out in Mail, untested.)

I've got the script working like a champ in a straight terminal  
session:

> /usr/bin/osascript '/Users/steve/Desktop/Restart.script'

So now:
NSString *cmdString = [NSString stringWithFormat:@"/usr/bin/ 
osascript '%@'",[[self scriptsFolderPath  
stringByAppendingPathComponent:@"Restart.script"]];

NSTask *task = [[[NSTask alloc] init] autorelease];
[task setLaunchPath:@"/bin/sh"];
[task setArguments:[NSArray arrayWithObjects:@"-c", cmdString, @"  
&", nil]];  		//the '&' detaches the shell, yes?


& only detaches a command when it's part of a shell command. You're  
passing it as an argument to /bin/sh here, which is subtly different.


___

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

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

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

This email sent to [EMAIL PROTECTED]


CoreFoundation Command Line Tool - an easy beginner question

2008-08-04 Thread Steve Cronin

Folks;

Here's the pretty simple tool I'm trying to create (THANK-YOU Michael  
Ash!!)


int main (int argc, const char * argv[]) {
char dummy;
read(STDIN_FILENO, &dummy, 1);
[NSAutoreleasePool new];
	NSURL *url = [NSURL fileURLWithPath:[NSString  
stringWithUTF8String:argv[1]]];

LSOpenCFURLRef((CFURLRef)url, NULL);
return 0;
}

I'm using XCode3.1 with the 10.5 SDK deploying to 10.4.
I open new project using the  CoreFoundation - Command Line Tool  
template, and place the code shown above.


My question is what are the #imports necessary to make this work?
I have figured out:
#import   
  //for the STDIN_FILENO and the read()
#import 		//for the  
LSOpenCFURLRef


I've tried various usages of #import  but  
can't seem to get it right so that NSURL & NSAutoreleasePool are  
defined...
I believe that both NSURL and NSAutoreleasePool are defined in the  
Foundation framework, which is why I am focused on getting it  
#imported,  I just need the syntax..

(with Foundation framework added to the project)
NO --> #include   (~700 errors...)
NO --> #include   (45 errors..)

Oh out of exasperation, I tried  ---> ~1700 errors

I know this is probably pretty easy for most, but its got me just  
bamboozled


THANK-YOU for any help!
Steve
___

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]


StatusItem to foreground app

2008-08-24 Thread Steve Cronin

Folks;

I'm building  a tool that I want to allow the user switch 'modes'  
either running as a menubar statusItem  or as regular dock-based  
application.


NOTE: The info.plist has LSUIElement=1.
If the user designates the application to run as regular dock-based  
application then, early in startup, I do:


ProcessSerialNumber psn = { 0, kCurrentProcess };
	OSStatus returnCode = TransformProcessType(&psn,  
kProcessTransformToForegroundApplication);

if( returnCode == 0) {
...

I have this working fine under Leopard, however, the application's  
deployment target is 10.4.

On the Tiger machines I'm getting a returnCode = -50.
GetMacOSStatusErrorString tells me that there is an error in the user  
parameters.

I have examined the psn high = 0 and low = 2 which seems right to me...

The 10.4 application does NOT die; rather it continues to load and run  
EXCEPT there is no menu bar, no dock icon, and it is not listed in  
'Force Quit'.  (The TransformProcessType has failed.)


Is the LSUIElement confusing 10.4?
Was this a known bug on 10.4 that was never fixed?
Was there a 10.4 workaround?

So here's my predicament:
I need the LSUIElement set to run as a statusItem (yes?)
LSUIElement cannot be changed by code (yes?)
If I have this set LSUIElement then I can ONLY run as a status item in  
10.4.
If I do not set LSUIElement then I can NEVER run as a status item in  
either Leopard or Tiger


I really don't want to deploy separate binaries for obvious reasons.
Does anyone have any insight into what is going on here?

Thanks for any thoughts!
Steve
___

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]


Built Menu not firing the action

2008-08-25 Thread Steve Cronin

Folks;

I'm building a data driven submenu programmatically.
The submenu appears correctly in the UI with the correct titles but  
nothing happens when these items are selected.


submenu build code:

menu1 = [[[NSMenu alloc] initWithTitle:@"__"] retain];
[menu1 setAutoenablesItems:NO];
NSEnumerator *titleEnum = [someArray objectEnumerator];
while ((nextTitle = [titleEnum nextObject])!=nil) {
		[menu1 addItemWithTitle:nextTitle  action:@selector(customAction:)  
keyEquivalent:@""];

}   
...
	[[mainMenu itemAtIndex:3] submenu] itemWithTag:1000] submenu]  
itemWithTag:1003] setSubmenu: menu1];



I spit menu1 out to NSLog and it looks fine.
I set a breakpoint at customAction:  it NEVER gets called.
(Yes I have spelled it correctly [- (void) customAction:(id)sender;]

This is on the mainMenu in the main XIB file.  There is an outlet from  
appDelegate for mainMenu, this is set.

The menu itself has the appDelegate set as its' delegate.
The selector method is o method in the appDelegate object.
There are no selector bindings set.
(Note: there are enabled bindings set which are working correctly)

I'm just stumped!  I probably could use some sleep...
Also how do you show some useful data from a SEL value in NSLog? ie  
print  [NSMenuItem action]?


Since nothing happens how do I debug this?
Thank-you for any insights!
Steve
___

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: Built Menu not firing the action

2008-08-25 Thread Steve Cronin

Peter;

Thanks for the tip on NSStringFromSelector()!

On the responder chain: I'm not sure I precisely understand your  
question - where are you expecting me to call this?
If I call it at the time the submenu is being constructed I get:  
appDelegate
Since I can't get any response to selecting the item itself, I can't  
tell you what I would get if I called it when the item is invoked  =;-(


If you use the NSMenu method -addItemWithTitle:(NSString *) action: 
(SEL)  keyEquivalent:(NSString *)
what is the recommended way to set the target for the menuItem added  
by this method?
Why doesn't the method allow you to set the target as well as the  
selector, in one fell swoop?


How can I effect the responder chain, if I am just adding a submenu to  
menuitem on the menubar?


The REAL maddening thing here is that I have another similar data  
driven submenu that uses the same mechanism and it works fine.
I've been over and over the IB settings for the darn things and I  
can't find any differences!
Same point in time the submenu are being constructed and attached; and  
same exact objects involved in the selector


Thanks for any additional data.
Steve



On Aug 25, 2008, at 1:20 PM, Peter Ammon wrote:



On Aug 25, 2008, at 12:53 AM, Steve Cronin wrote:


Folks;

I'm building a data driven submenu programmatically.
The submenu appears correctly in the UI with the correct titles but  
nothing happens when these items are selected.



[...]


I set a breakpoint at customAction:  it NEVER gets called.
(Yes I have spelled it correctly [- (void) customAction:(id)sender;]

This is on the mainMenu in the main XIB file.  There is an outlet  
from appDelegate for mainMenu, this is set.

The menu itself has the appDelegate set as its' delegate.
The selector method is o method in the appDelegate object.
There are no selector bindings set.
(Note: there are enabled bindings set which are working correctly)


The most likely problem is that the object implementing the method  
is not in the responder chain.  What object do you get if you call  
[NSApp targetForAction:@selector(customAction:)]?





I'm just stumped!  I probably could use some sleep...
Also how do you show some useful data from a SEL value in NSLog? ie  
print  [NSMenuItem action]?


For debugging purposes, the easiest thing to do is to cast it to a  
char*, e.g.:


gdb)  p (char *)[someMenuItem action]

For your actual code, you should use the NSStringFromSelector()  
function, as the char* nature of selectors is not guaranteed.


-Peter



___

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]


Strange Strange Bug

2008-09-05 Thread Steve Cronin

Folks;

OK this behavior has me a little spooked...
This behavior occurs the first time through the method!
I have a breakpoint set at the first line of a method, which happens  
to be a NSLog(@"Ready");
As is normal I have my local variable declarations at the beginning of  
the method:

NSArray *myKeys, *workingValues;
	NSString *gAsOf, *gAsOfDate,  *gDataMask, *gDataMaskName, *gID,  
*gIDName, *gVersion, *gVersionName;
	gAsOfDateName = [[NSUserDefaults standardUserDefaults]  
stringForKey:@"groupAsOfDatePropertyName"];
	gDataMaskName = [[NSUserDefaults standardUserDefaults]  
stringForKey:@"groupDataMaskPropertyName"];


Nothing surprising or complicated...

However, the console window will show at least two of these messages:.
2008-09-05 00:56:45.101 XYZ[345:813] *** -[CFString _cfTypeID]:  
message sent to deallocated instance 0x16d1db80
2008-09-05 00:56:45.563 XYZ[345:813] *** -[CFString _cfTypeID]:  
message sent to deallocated instance 0x16d1db80
2008-09-05 00:56:46.776 XYZ[345:813] *** -[CFString _cfTypeID]:  
message sent to deallocated instance 0x16d1db80


If I scroll the variables display at the upper right in the debugger  
window, the console will add more of these messages.
One of the strings in the variable display will have its 'Value' shown  
as the instance id shown in these messages.
For this string variable the 'Summary' will be empty as opposed to all  
other 'Summary' which have 'Invalid'
The debugger is paused several lines above the declaration of this  
variable...


If I merely switch the positions of the variables I can change which  
variable has the 'bad' instance id.

It is always the 6th declared string variable.
I can mix up the order of variables, change the actual variable names,  
or interleave NSArray declarations, it doesn't matter...the 6th string  
exhibits this behavior.
Hovering over the variable it displays the 'yellow help ribbon' with  
'NSZombie_CFString', whereas all the others are 'NSString'

Commenting out the declarations and use and compiling works fine.
Uncommenting brings back the exact behavior.

Note:  If I take out the breakpoint then the console does NOT show  
these messages even though I have left log messages in the method so I  
know the method is being executed


I have restarted XCode as well as the system (Intel 10.5.4, XC3.1) no  
change


What in the heck is going on?  Should I be worried? How can I shed  
this anomaly?


Thanks,
Steve

___

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: Strange Strange Bug

2008-09-05 Thread Steve Cronin

Kai;

OK That seems reasonable but:

why do I not see this behavior anywhere else?

why have I never seen it before now?

why if I restart XCode does the 'bad' instance fall on exactly the  
same string?


Thanks,
Steve
On Sep 5, 2008, at 4:11 AM, Kai wrote:


Steve,

looks like the debugger tries to inspect your uninitialized string  
pointers. And it happens that the stack location assigned to the 6th  
string pointer still contains the address of a now deallocated  
object left there when another method exited.


So this is a debugger-only problem and completely harmless without  
debugger (if I am not mistaken, of course).


To fix it, assign nil to the string pointers when you declare them:

NSString *gAsOf = nil;
etc..

Or, better yet, do not declare the variables before using them (that  
is, not all together at the start of the method). (Note that this  
style may be only possible with certain C dialects. I use Objective C 
++, therefore I’m not sure).


Hope this helps.
Kai


On 5.9.2008, at 09:04, Steve Cronin wrote:


Folks;

OK this behavior has me a little spooked...
This behavior occurs the first time through the method!
I have a breakpoint set at the first line of a method, which  
happens to be a NSLog(@"Ready");
As is normal I have my local variable declarations at the beginning  
of the method:

NSArray *myKeys, *workingValues;
	NSString *gAsOf, *gAsOfDate,  *gDataMask, *gDataMaskName, *gID,  
*gIDName, *gVersion, *gVersionName;
	gAsOfDateName = [[NSUserDefaults standardUserDefaults]  
stringForKey:@"groupAsOfDatePropertyName"];
	gDataMaskName = [[NSUserDefaults standardUserDefaults]  
stringForKey:@"groupDataMaskPropertyName"];


Nothing surprising or complicated...

However, the console window will show at least two of these  
messages:.
2008-09-05 00:56:45.101 XYZ[345:813] *** -[CFString _cfTypeID]:  
message sent to deallocated instance 0x16d1db80
2008-09-05 00:56:45.563 XYZ[345:813] *** -[CFString _cfTypeID]:  
message sent to deallocated instance 0x16d1db80
2008-09-05 00:56:46.776 XYZ[345:813] *** -[CFString _cfTypeID]:  
message sent to deallocated instance 0x16d1db80


If I scroll the variables display at the upper right in the  
debugger window, the console will add more of these messages.
One of the strings in the variable display will have its 'Value'  
shown as the instance id shown in these messages.
For this string variable the 'Summary' will be empty as opposed to  
all other 'Summary' which have 'Invalid'
The debugger is paused several lines above the declaration of this  
variable...


If I merely switch the positions of the variables I can change  
which variable has the 'bad' instance id.

It is always the 6th declared string variable.
I can mix up the order of variables, change the actual variable  
names, or interleave NSArray declarations, it doesn't matter...the  
6th string exhibits this behavior.
Hovering over the variable it displays the 'yellow help ribbon'  
with 'NSZombie_CFString', whereas all the others are 'NSString'

Commenting out the declarations and use and compiling works fine.
Uncommenting brings back the exact behavior.

Note:  If I take out the breakpoint then the console does NOT show  
these messages even though I have left log messages in the method  
so I know the method is being executed


I have restarted XCode as well as the system (Intel 10.5.4, XC3.1)  
no change


What in the heck is going on?  Should I be worried? How can I shed  
this anomaly?


Thanks,
Steve

___

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/kai%40granus.net

This email sent to [EMAIL PROTECTED]




___

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]


Dragging tableView rows to an external applications

2008-09-23 Thread Steve Cronin

Folks;

I'm trying in 10.4+ to implement dragging data from a tableView to the  
desktop.

My problem is probably a dunderhead oversight but I can't see it.

I have NOT subclassed an NSTableView.
In a windowController I do the following in -awakeFromNib:   
(myTableView is an Outlet)

...
[myTableView registerForDraggedTypes:[NSArray  
arrayWithObjects:NSFilenamesPboardType, NSFilesPromisePboardType, nil]];
[myTableView setDraggingSourceOperationMask:NSDragOperationNone  
forLocal:YES]; //local
[myTableView setDraggingSourceOperationMask:NSDragOperationCopy  
forLocal:NO]; // external

...

I get a local copy, drag some selected rows initiates a 'carrying'  
cursor,  but as soon as I leave my application it invalidates.

This is exactly the opposite of the desired/expected behavior...
NOTE: If I change both drag operations in the  
setDraggingSourceOperation method to NSDragOperationEvery - no  
difference.


myTableView has the windowController set as its delegate.
The tableView:writeRowsWithIndexes:toPasteboard is being called (its  
in the windowController too)


What am I overlooking?
Steve
___

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]


Horizontal SplitView Resize Question

2008-09-25 Thread Steve Cronin

Folks;

I have a horizontal split bar inside of a resizable view -the parent  
view grows both horizontally and vertically.
The standard behavior for horizontal split views appears to be that  
the the bottom view is grown or shrunk.
(In my testing this is true regardless of the resize attributes of the  
enclosed bottom view)

I have ALL of the resize widgets set ON for this splitView.

What I would like is the divider to stay fixed at its current height  
from the bottom throughout a resize and the top view to grow or shrink.
Is there a setting I am overlooking or is the way to accomplish this  
by overriding -splitViewDidResizeSubviews?


Thanks,
Steve
___

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]


NSIndexSet isEqual: sent to deallocated instance

2008-10-08 Thread Steve Cronin

Folks;

I have two custom tableViews and two custom arrayControllers.
The reasons for the custom objects are so the UI can respond to  
specific key events and for drag and drop support.
Both tableView have their appropriate arrayControllers designated as  
delegates and datasources.

The tableViews use bindings to define the column values.
The selection in one tableView controls the content of the other -  
this is implemented by using 'filteredArray' against a 'backing' array.

Overall, this is largely working pretty well.

Under some circumstances the the backing array is refreshed with new  
content.

When this happens, sometimes, not always, an error is thrown:
 *** -[NSIndexSet isEqual:]: message sent to deallocated instance  
0x184de440

#0  0x92028907 in ___forwarding___
#1  0x92028a12 in __forwarding_prep_0___
#2  0x967fadb9 in _NSValuesAreEqual
#3  0x9683e9e6 in -[NSTableBinder _updateSelectionIndexes:]
#4	0x9683e073 in -[NSTableBinder  
_observeValueForKeyPath:ofObject:context:]
#5	0x9683dd6d in -[NSTableBinder  
observeValueForKeyPath:ofObject:change:context:]

#6  0x93d77ece in NSKVONotify
#7	0x93d08465 in -[NSObject(NSKeyValueObservingPrivate)  
_notifyObserversForKeyPath:change:]

#8  0x9661cd7a in -[NSController _notifyObserversForKeyPath:change:]
#9  0x9661cc7b in -[NSController didChangeValueForKey:]
#10	0x96838ce4 in -[NSArrayController  
didChangeValuesForArrangedKeys:objectKeys:indexKeys:]
#11	0x9683bb44 in -[NSArrayController  
_arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask:useBasis 
:]

#12 0x96836a7a in -[NSArrayController setContent:]
#13	0x9683d2a2 in -[NSArrayDetailBinder  
_refreshDetailContentInBackground:]

#14 0x93d77ece in NSKVONotify
#15	0x93cf4392 in -[NSObject(NSKeyValueObserverNotification)  
didChangeValueForKey:]
#16	0x000cb3a9 in -[MyWindowController refreshViews] at  
MyWindowController.m:347


I do not have either tableViews 'selectionIndexes' bound.
I'm puzzled by the intermittent nature and, as with all binding  
related errors, find it simply maddening to try and debug.
I can't seem to 'step' my way up/into the error, it is tripped  
somewhere in 'binding space'...


Does anyone have any useful feedback?
(10.5 SDk deploy target 10.4)

Thanks,
Steve
___

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]


10.4 v. 10.5 SDK question

2008-10-17 Thread Steve Cronin

Folks;

I have developed an application with XC 3.1 on a 10.5 Intel machine  
using the 10.5 SDK w/ a 10.4 deployment target.

(No GC for me!)

In testing I immediately ran into a few difficulties on a 10.4 PPC  
machine.
In the course of tracking down these issues I ended up installing XC  
2.5 on this 10.4 PPC machine.
I actually compiled the application under the 10.4 SDK on this machine  
so I could run it in the debugger.
(I had to make surprisingly few changes to get this to happen - none  
that I am unhappy about)
Converting all .xib to .nib being one major aspect (and where I found  
the offending bug [filter predicate bindings...])
In fact, this exercise has left me with an increased confidence in the  
application's behavior in this environment.


So I've moved the modified project back to the 10.5 Intel where it  
happily compiles and runs still using the 10.4 SDK and .nibs.


So, given all that, am I correct in wanting to move the project back  
to the 10.5 SDK because the underlying code is cleaner and the  
compiler output is better?
(Yes, I do understand the benefits of .xibs but let's leave that aside  
for now)


Frankly, I would like to better understand all the implications of  
this choice.

Thanks for any input!
Steve
___

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: 10.4 v. 10.5 SDK question

2008-10-17 Thread Steve Cronin

Ken;

Thanks for the quick and helpful response!

You seem to have assumed that you can only compile against the 10.4  
SDK by going back to Xcode 2.5 (and thus using an earlier compiler).


No I brought the application back to the 10.5 machine and have left it  
compiling against the 10.4 SDK for now.
Trying to decide whether to return to using the 10.5 SDK was the  
genesis of my question.


In general, your choice of SDK should be dictated by the latest  
features you want to use.  If you don't want to use any 10.5-or- 
later-only features, sticking with the 10.4 SDK is safest.
I want to deploy to 10.4 and have avoided using 10.5 features to keep  
the code base clean and simple.
My plan was to prove out the product idea using the widest possible  
audience (10.4) using the simplest most widely understood and sampled  
code - 10.4 only.
If successful, then version 2 would be a 10.5 only product developed  
using a by then more battle-tested 10.5.
Version 2 is also then a clean code base because it also avoids all  
the OS-version conditionals you mentioned.



Also, what do you mean "the underlying code is cleaner"?  ..
One caveat with simply using the 10.4 SDK, though -- the 10.5  
frameworks contain a number of bug fixes

That's what I meant.

...(bug fixes) which are only enabled for binaries linked against  
the 10.5 SDK.  This is both a good and bad thing.  It means your  
program works consistently on Tiger and Leopard, which makes testing  
easier.  But it might behave consistently incorrectly due to the  
bugs.  Check the various Leopard release notes for specifics.

I'm afraid I don't understand this comment.
What do you mean "..behave consistently incorrectly due to the bugs.."?
Can you refer me to a specific item you might be thinking of here?

So in sum, I think what you are saying is:
Stick w/ 10.4 SDK as the safest path.
However there might be bug fixes which you could benefit from by using  
the 10.5 SDK.
To determine whether or not you actually do benefit from 10.5 means  
you have to learn more about it by reading the Release Notes.

Does that sound right?

So based on this reading of your comments and a few minutes with the  
XCode documentation I scan the AppKit Release Notes for Leopard and  
find the following:

NSCompoundPredicate

For applications linked on Mac OS X 10.5 "Leopard" or later,  
initializing an NSCompoundPredicate now copies the subpredicates array  
rather than retaining it. Applications linked on Mac OS X 10.4 "Tiger"  
continue to only retain the subpredicates array for binary  
compatibility.



Well this appears germane to my application as I do use compound  
predicates.
Judging by the scope the Release Notes and the speed with which I  
could locate even one germane issue I am convinced that my original  
instinct to use the 10.5 SDK because the code base is better IS correct.


But I am puzzled by your "good and bad thing" comment...

Thanks Again,
Steve



On Oct 18, 2008, at 12:18 AM, Steve Cronin wrote:

I have developed an application with XC 3.1 on a 10.5 Intel machine  
using the 10.5 SDK w/ a 10.4 deployment target.

(No GC for me!)

In testing I immediately ran into a few difficulties on a 10.4 PPC  
machine.
In the course of tracking down these issues I ended up installing  
XC 2.5 on this 10.4 PPC machine.
I actually compiled the application under the 10.4 SDK on this  
machine so I could run it in the debugger.
(I had to make surprisingly few changes to get this to happen -  
none that I am unhappy about)
Converting all .xib to .nib being one major aspect (and where I  
found the offending bug [filter predicate bindings...])
In fact, this exercise has left me with an increased confidence in  
the application's behavior in this environment.


So I've moved the modified project back to the 10.5 Intel where it  
happily compiles and runs still using the 10.4 SDK and .nibs.


So, given all that, am I correct in wanting to move the project  
back to the 10.5 SDK because the underlying code is cleaner and the  
compiler output is better?



Also, what do you mean "the underlying code is cleaner"?  You are  
linking against the frameworks dynamically.  You get the framework  
for the OS on which you're running.  Regardless of what SDK you link  
against at build time, you're still linking against the libraries of  
your runtime environment.


In general, your choice of SDK should be dictated by the latest  
features you want to use.  If you don't want to use any 10.5-or- 
later-only features, sticking with the 10.4 SDK is safest.  The  
reason is that the compiler will warn you if you accidentally slip  
up and make use of a newer feature.


If you want to make use of 10.5 features but still deploy to 10.4,  
you have to take extra care.  That's why it's not good to do so  
accidentally.  You need to conditionalize all uses of 10.5 f

Re: 10.4 v. 10.5 SDK question

2008-10-18 Thread Steve Cronin

Ken;

Once again, thanks for the exemplary response!
(You are a great resource for the Cocoa community!)

So...  while yes, the 10.5 SDK does have bug fixes, using it and  
deploying to 10.4 potentially bifurcates the product into different  
behaviors.
(It is really tough to determine where and when these differences  
might show up but the possibility exists -.> maddening from a support  
perspective)


Since my goal was to deploy to 10.4 all along, by using the 10.4 SDK,  
the app will behave the same on both 10.4 and 10.5 (and 10.6) -->  
simpler from a support perspective.
In some cases the behavior might be consistently wrong perhaps but any  
such incorrectness can be cured on both OSes by the same workaround -- 
> simpler development and testing


Simpler development, simpler code, simpler testing,  simpler support   
- yeah!


Thanks for helping me better understand and for keeping my life simple!
Steve

On Oct 18, 2008, at 2:19 AM, Ken Thomases wrote:


On Oct 18, 2008, at 1:36 AM, Steve Cronin wrote:

...(bug fixes) which are only enabled for binaries linked against  
the 10.5 SDK.  This is both a good and bad thing.  It means your  
program works consistently on Tiger and Leopard, which makes  
testing easier.  But it might behave consistently incorrectly due  
to the bugs.  Check the various Leopard release notes for specifics.

I'm afraid I don't understand this comment.
What do you mean "..behave consistently incorrectly due to the  
bugs.."?


I mean that, where there's a bug, an application linked against the  
10.4 SDK will continue to get the buggy behavior from the framework,  
even when running on Leopard.  Consistency.  Whatever workaround you  
have for the bug will continue to work correctly on Leopard.


If you link against the 10.5 SDK, then the application will get one  
kind of behavior when running on Tiger and get a different behavior  
when running on Leopard.  Inconsistency.  Any workaround for the  
Tiger bug may cause trouble when running on Leopard, but failure to  
work around the bug will cause trouble when running on Tiger.  You  
have to write your code with this in mind, and you have to test both  
possibilities.



Can you refer me to a specific item you might be thinking of here?


Well, any of the bugs fixes listed in the release notes which note  
that the new behavior only occurs for applications linked against  
10.5.  For example, in the AppKit release notes, see the item titled  
"KeyValueObserving notifications for IBOutlets during Nib loading".   
Consider how easy it would be to unwittingly code an application  
that relies either on the old behavior which would break with the  
new behavior, or vice versa.




So in sum, I think what you are saying is:
Stick w/ 10.4 SDK as the safest path.
However there might be bug fixes which you could benefit from by  
using the 10.5 SDK.
To determine whether or not you actually do benefit from 10.5 means  
you have to learn more about it by reading the Release Notes.

Does that sound right?


Yup.


So based on this reading of your comments and a few minutes with  
the XCode documentation I scan the AppKit Release Notes for Leopard  
and find the following:
NSCompoundPredicateFor applications linked on Mac OS X 10.5  
"Leopard" or later, initializing an NSCompoundPredicate now copies  
the subpredicates array rather than retaining it. Applications  
linked on Mac OS X 10.4 "Tiger" continue to only retain the  
subpredicates array for binary compatibility.


Well this appears germane to my application as I do use compound  
predicates.
Judging by the scope the Release Notes and the speed with which I  
could locate even one germane issue I am convinced that my original  
instinct to use the 10.5 SDK because the code base is better IS  
correct.


But I am puzzled by your "good and bad thing" comment...


Well, consider this: if the bug fix were purely good, why would  
Apple maintain backward compatibility for apps which are linked  
against the 10.4 SDK?


And remember, if you link against the 10.5 SDK but support  
deployment on 10.4, then you still have to cope with the case where  
NSCompoundPredicate merely retains rather than copying its  
subpredicates array, because that's what will happen when it's run  
on 10.4.  So, your code has to be safe under both behaviors rather  
than just having one behavior to worry about.


Cheers,
Ken



___

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]


How to debug a loadNib error in a Release version?

2009-01-29 Thread Steve Cronin

Folks;

An Australian tester is reporting the crash shown below...
How can I best attack this problem?
What kind of IB setting causes a 'makeObjectsPerformSelector:'?
I do not directly call such a method in my code at all.
What do I make of the 'CFRelease' at frame 0?

What can I do to facilitate trapping this in a release version?
Since I have a number of other testers who are not having this problem  
at all, there something about this testers contextual data which is  
toasting me.

This tester is 10.4 and most are 10.5.
I have a 10.4 test environment which does not exhibit this behavior.

Thanks for any assistance,
Steve

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:  KERN_PROTECTION_FAILURE (0x0002) at 0x0006

Thread 0 Crashed:
0   com.apple.CoreFoundation0x907bebd8 CFRelease + 92
1   com.myApp.coolApp   0x00021464 0x1000 + 132196
2   com.myApp.coolApp   0x0009a328 0x1000 + 627496
3   com.myApp.coolApp   0x00099f44 0x1000 + 626500
4   com.myApp.coolApp   0x00016bfc 0x1000 + 89084
5   com.myApp.coolApp   0xd430 0x1000 + 50224
6   com.apple.Foundation 	0x92bff5e8 -[NSSet  
makeObjectsPerformSelector:] + 164
7   com.apple.AppKit 		0x937cd6c0 -[NSIBObjectData  
nibInstantiateWithOwner:topLevelObjects:] + 864

8   com.apple.AppKit0x937b98ec loadNib + 240
9   com.apple.AppKit 		0x937b9344 +[NSBundle(NSNibLoading)  
_loadNibFile:nameTable:withZone:ownerBundle:] + 716
10  com.apple.AppKit 		0x93810814 +[NSBundle(NSNibLoading)  
loadNibFile:externalNameTable:withZone:] + 156
11  com.apple.AppKit 		0x938a064c +[NSBundle(NSNibLoading)  
loadNibNamed:owner:] + 344

12  com.apple.AppKit0x938a03ec NSApplicationMain + 344
13  com.myApp.coolApp   0x2f20 0x1000 + 7968
14  com.myApp.coolApp   0x2c24 0x1000 + 7204

___

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 debug a loadNib error in a Release version?

2009-01-29 Thread Steve Cronin

Corbin;

Thanks for responding!
I don't understand "..Symbolicate your backtrace.."

Can you take a moment and educate me on this?
Thanks!
Steve

On Jan 29, 2009, at 1:24 PM, Corbin Dunn wrote:



On Jan 29, 2009, at 9:54 AM, Steve Cronin wrote:


Folks;

An Australian tester is reporting the crash shown below...
How can I best attack this problem?
What kind of IB setting causes a 'makeObjectsPerformSelector:'?


-awakeFromNib is being called.


I do not directly call such a method in my code at all.
What do I make of the 'CFRelease' at frame 0?


Symbolicate your backtrace; that will help you figure out the problem.

corbin


___

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


Sizing table columns to fit data - a solution looking for suggestions

2009-01-29 Thread Steve Cronin

Folks;

iTunes and Excel both have a feature wherein if you double-click on  
the column divider in the tableHeader then the table column width is  
adjusted to the maximum width of the data in the column.


Below is a reasonably generic Cocoa solution for implementing this  
behavior.
The tableView I developed this for uses an arrayController with  
individual column bindings; not the old school -dataSource methods for  
handling the data.

This code should exist in tableView's delegate.
This solution handles both strings and images.
I don't like the reliance on calling the arrayController directly but  
for now it serves my purpose


I am interested in both criticisms and improvements - both will serve  
the Cocoa community..


- (void)tableView:(NSTableView *)tableView  
mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn {	

NSEvent *event = [NSApp currentEvent];
if ([event clickCount]==2) {
NSPoint location = [event locationInWindow];
NSTableHeaderView *header = [tableView headerView]; 
location = [header convertPoint:location fromView:nil];
		if (location.x>=2.0) location.x-=2;  // offset point 2 pixels 'cause  
the 'split' cursor is a little 'permissive'
		NSTableColumn *thisColumn = [[tableView tableColumns] objectAtIndex: 
[header columnAtPoint:location]];

NSString *maxStr = @"";
id thisObj;
NSCell *dCell;
float newWidth, maxStringWidth =  0.0 ,maxImageWidth = 0.0;
// me don't like the next line
		NSArray *theValues = [[myArrayController arrangedObjects]  
valueForKey:[thisColumn identifier]];  //dump the tableColumn values  
to an array

if ((theValues!=nil) && ([theValues count]>0)) {
NSEnumerator *valEnum = [theValues objectEnumerator];
// find the longest string or widest image
while ((thisObj = [valEnum nextObject]) != nil) {
if ([thisObj isKindOfClass:[NSString class]]) {
	if ([thisObj length] > [maxStr length]) maxStr = thisObj;   // 
keep the string 'cause later we use dataCell to get -width

} else if ([thisObj isKindOfClass:[NSImage 
class]]) {
	if ([thisObj size].width > maxImageWidth) maxImageWidth =  
[thisObj size].width;

}
}
			//below covers the case where a mix of strings and images were  
found - chooses the wider of the two

if ([maxStr length]> 0) {
dCell = [thisColumn dataCell];
[dCell setStringValue:maxStr];
maxStringWidth = [dCell cellSize].width;
}
			newWidth = (maxStringWidth > maxImageWidth) ? maxStringWidth :  
maxImageWidth;
			//this check prevents anything from happing unless we have found  
something actionable

if (newWidth>0) {
//bump up max if necessary
if (newWidth>[thisColumn maxWidth]) [thisColumn  
setMaxWidth:newWidth];

//set width to max if not already max
if ([thisColumn width] != newWidth) {
[thisColumn setWidth:newWidth];
} else {
	//if already max then here double-click sets to half max!  (maybe  
NOT do this if images were found?)

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

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


Re: Sizing table columns to fit data - a solution looking for suggestions

2009-01-30 Thread Steve Cronin

Corbin;

Hey thanks for replying!

First off, don't use the 'tableView:' prefix for your own delegate  
methods. Consider what would happen if AppKit introduced the same  
delegate method in a future release. Well, I can tell you from  
experience that it won't be good. So, please make it something like  
"scTableView:...".


This method is an existing method provided by NSObject from Apple!  I  
didn't make the name up, I used an already existing delegate mechanism.

Am I not understanding your point?


Use CGFloat not float.


OK, but why?

Setting the width in a loop is not good for performance; it might  
cause the table to relayout a lot of times.


The code you cited is NOT inside a loop!?? Or am I not understanding  
how something works?



  NSCell *cell = [tableView preparedCellAtRow:i column:column];


10.5 Only -- I wanted a 10.4 compatible solution.  I didn't say that  
and I should have.


Thanks,
Steve



On Jan 30, 2009, at 10:10 AM, Corbin Dunn wrote:

Below is a reasonably generic Cocoa solution for implementing this  
behavior.
The tableView I developed this for uses an arrayController with  
individual column bindings; not the old school -dataSource methods  
for handling the data.

This code should exist in tableView's delegate.
This solution handles both strings and images.
I don't like the reliance on calling the arrayController directly  
but for now it serves my purpose


Overall, I would do it slightly differently; I would subclass  
NSTAbleHeaderView, figure out what column needs it to be autoresized  
and when (ie: double click), and then ask the delegate (optionally)  
what size it wants. But, I would make a default implementation based  
on -cellSize (possibly doing a monte carlo simulation on the number  
of rows, if there were a lot of rows, to help with performance).


Here are comments on your version:



I am interested in both criticisms and improvements - both will  
serve the Cocoa community..


- (void)tableView:(NSTableView *)tableView  
mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn {	





NSEvent *event = [NSApp currentEvent];
if ([event clickCount]==2) {
NSPoint location = [event locationInWindow];
NSTableHeaderView *header = [tableView headerView]; 
location = [header convertPoint:location fromView:nil];
		if (location.x>=2.0) location.x-=2;  // offset point 2 pixels  
'cause the 'split' cursor is a little 'permissive'
		NSTableColumn *thisColumn = [[tableView tableColumns]  
objectAtIndex:[header columnAtPoint:location]];

NSString *maxStr = @"";
id thisObj;
NSCell *dCell;
float newWidth, maxStringWidth =  0.0 ,maxImageWidth = 0.0;


Use CGFloat not float.


// me don't like the next line
		NSArray *theValues = [[myArrayController arrangedObjects]  
valueForKey:[thisColumn identifier]];  //dump the tableColumn  
values to an array



Instead of this hardcoded access, do this (sorry, not complete, but  
you should understand the idea):


CGFloat maxWidth = 0;
for (NSInteger i = 0; i < tableView.numberOfRows; i++) {
  NSCell *cell = [tableView preparedCellAtRow:i column:column];
  NSSize size = [cell cellSize];
  if (size.width > maxWidth) maxWidth = size.width;
}
[tableColumn setWidth:maxWidth];

The code above is *much* more generic. Note that it doesn't consider  
the indentation for outlineviews.


if ([thisColumn width] != newWidth) {
[thisColumn setWidth:newWidth];


Setting the width in a loop is not good for performance; it might  
cause the table to relayout a lot of times.


Anyways, as usual, it never hurts to log feature requests for AppKit  
to do this for you.


corbin


} else {
	//if already max then here double-click sets to half max!   
(maybe NOT do this if images were found?)

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

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


NSService - I need a headslap

2009-02-04 Thread Steve Cronin

Folks;

I have a need for a stand-alone service.
Seems like Service don't get alot of love... (Maybe that's my  
problem .. but I don't think so)


To be clear here, this is a stand-alone .service type application (not  
a service vended by a larger app (like Mail).


Here's what I have done:
0) built with a .service wrapper
1) Info.plist - PrinClass=NSApp; Bundle OS Type = APPL;  
ExecutableFile=MyClassName; App is BackgroundOnly
1) Info.plist - Services{Menu, SendType, instance method name, and  
incoming service port name)

2) No xib file
3) standard main.m
4) I have a single ObjC class whose .m looks like this

+(void)initialize { [NSApp setDelegate:self]; }

- (void) applicationDidFinishLaunching:(NSNotification *)aNote {
[NSApp setServicesProvider:self];
void NSUpdateDynamicServices(void);
}

- (void) myServiceName:(NSPasteboard *)pboard userData:(NSString  
*)userData error:(NSString **)error {

.
}

What I can't get my head wrapped around is how/when does this .service  
thing get launched?
The docs seem to indicate that you can just build it as a .service,  
stuff into the ~/Library/Services and you are good to go...

(These docs are more than 8 years old Is there any later material?)

On Tiger systems I see the service appear on the Services menu   
Not so on Leopard
(On Leopard even if I log out and back in I still do not see the  
service in the menu...
But either way I never get any response.  If I put in log statements I  
never see any activity...
What am I overlooking?  I KNOW its something silly but have mercy my  
head is bloody


Thanks for any help!!
Steve
___

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: NSService - I need a headslap

2009-02-04 Thread Steve Cronin
Well, sheesh - that's embarrassing!   There is no 'self' until init -  
I know that!  Ugh.


However, that doesn't change my end result!

I never see anything on the Services menu nor anything from the NSLog  
statements shown below.
(Even when I double-click on the .service file;  after whcih I CAN see  
it in the process list in Activity monitor but still no log messages)
Logging out and back in doesn't make my service name appear on the  
Service menu...
This is on a 10.5.6 system using a Release build which has been placed  
in ~/Library/Services.


SO my basic questions still stand:
What event/conditions launches a .service which resides in ~/Library/ 
Services?

Should/must .service files be 'Background Only'?
Am I missing something basic in my setup here -
I have only a Info.plist and 1 .h (NSObject) and 2 . m files (main and  
MyService) and no .xib?
Other than the 'wrapper' settings are there other compiler settings  
required for this setup?
I have only 2 steps in my build process: 'Compile Source (2)' and  
'Link Binary w/ Lib (1)' [Cocoa]


To me it feels like there is something basic about the application  
package that is not right but then I can't seem to keep 'self'  
straight either...


MyService.m

-(id) init {
[super init];   
NSLog(@"*[%@ %...@]",[self class],NSStringFromSelector(_cmd));
[NSApp setDelegate:self];
return self;
}
- (void) applicationDidFinishLaunching:(NSNotification *)aNote {
[NSApp setServicesProvider:self];
void NSUpdateDynamicServices(void);
}

- (void) myServiceName:(NSPasteboard *)pboard userData:(NSString  
*)userData error:(NSString **)error {

.
}




On Feb 4, 2009, at 5:47 AM, Ron Fleckner wrote:



On 04/02/2009, at 7:44 PM, Steve Cronin wrote:


+(void)initialize { [NSApp setDelegate:self]; }


Hi Steve,

as Quincey has suggested, looks like the above is the problem.  I've  
done a stand-alone .service and [NSApp setDelegate:self] is in -  
(id)init, not + (void)initialize.


Ron


___

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: NSService - I need a headslap

2009-02-04 Thread Steve Cronin

Peter;

Thanks for the response!
Launched on demand based on the Service specifications in Info.plist  
-  there that's a big conceptual milestone!  Thank-you!!

(I wish that was written down somewhere I could find...)
So for a stand-alone service should we -terminate after each call?

Here's how I'm installing the .service:

	servicesFolderPath =  
[[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,  
NSUserDomainMask, YES) objectAtIndex:0]  
stringByAppendingPathComponent:@"Services"];

if (![fileManager fileExistsAtPath:servicesFolderPath]) {
[fileManager createDirectoryAtPath:servicesFolderPath 
attributes:nil];
}
	srcPath = [[NSBundle  bundleForClass:[self class]]  
pathForResource:@"MyService" ofType:@"service"];
	destPath =  [servicesFolderPath  
stringByAppendingPathComponent:@"MyService.service"];
	if ( ([fileManager fileExistsAtPath:srcPath]) && (![fileManager  
fileExistsAtPath:destPath]) )  {

[fileManager copyPath:srcPath toPath:destPath handler:nil];
NSUpdateDynamicServices();
}  else {
if (![fileManager fileExistsAtPath:srcPath]) {
_WDIfV NSLog(@"MyService.service - Payload Not 
Located.");
} else {
_WDIfV NSLog(@"MyService.service was already 
installed.");
}
}   

Nothing appears in the Service menu on Leopard EVER, even after re- 
logging in.
What I observe is that on Tiger, after installing as above, the next  
time I launch any application its Service menu DOES include my item...


Here's the Info.plist:

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



CFBundleInfoDictionaryVersion
6.0
NSPrincipalClass
NSApplication
CFBundleIdentifier
com.mycompany.myService
CFBundlePackageType
APPL
CFBundleVersion
1.0.0
LSBackgroundOnly

CFBundleIconFile
MyIcony
CFBundleGetInfoString
	Version 1.0, Copyright © 2009 My Company.  All rights  
reserved.

NSHumanReadableCopyright
Copyright © 2009, My Company.
All rights reserved.
LSMinimumSystemVersion
10.4
CFBundleExecutable
MyService
CFBundleName
MyService
NSServices


NSMessage
myServiceMethod
NSPortName
MyService
NSMenuItem

Menu item title
MyService

NSSendTypes

NSStringPboardType
NSRTFPboardType








On Feb 4, 2009, at 2:37 PM, Peter Ammon wrote:


Hi Steve,

What appears in the Services menu is entirely determined by the  
NSServices portion of your Info.plist.  If you post that to the  
list, we can look for any problems.


Your Service is launched on-demand when the user selects it from the  
menu.  Services may be background only, but do not have to be.


On Tiger and earlier, there is no way to avoid needing to log in and  
out.  On Leopard, you can use the function NSUpdateDynamicServices()  
to immediately scan for new Services.  If you're just testing, a  
quick way to scan for new Services is to run pbs directly:


   /System/Library/CoreServices/pbs

However, pbs has no supported public interface and this will (has  
already) change, so don't include any reference to pbs in a script.   
NSUpdateDynamicServices() is the right way to programmatically  
refresh Services.


-Peter

On Feb 4, 2009, at 7:03 AM, Steve Cronin wrote:

Well, sheesh - that's embarrassing!   There is no 'self' until init  
- I know that!  Ugh.


However, that doesn't change my end result!

I never see anything on the Services menu nor anything from the  
NSLog statements shown below.
(Even when I double-click on the .service file;  after whcih I CAN  
see it in the process list in Activity monitor but still no log  
messages)
Logging out and back in doesn't make my service name appear on the  
Service menu...
This is on a 10.5.6 system using a Release build which has been  
placed in ~/Library/Services.


SO my basic questions still stand:
What event/conditions launches a .service which resides in ~/ 
Library/Services?

Should/must .service files be 'Background Only'?
Am I missing something basic in my setup here -
I have only a Info.plist and 1 .h (NSObject) and 2 . m files (main  
and MyService) and no .xib?
Other than the 'wrapper' settings are there other compiler settings  
required for this setup?
I have only 2 steps in my 

Re: NSService - I need a headslap

2009-02-04 Thread Steve Cronin

Peter;

I think I may have found into the core issue for me:

I don't have a xib file in this stand-alone app.
In main.m the invocation of NSApplicationMain() is equivalent to:
void NSApplicationMain(int argc, char *argv[]) {
[NSApplication sharedApplication];
[NSBundle loadNibNamed:@"myMain" owner:NSApp];
[NSApp run];
}

As you can see from my Info.plist sent earlier I don’t have ‘Main nib  
file base name’ set.

Could this cause the whole app to just go plunk?

Would I need to subclass NSApplication instead of NSObject here?
(Yikes that sound BIG?)  (I’d need to switch out Principal Class in  
Info.plist to be MyService, yes?)

What would main.m need to look like then?

int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
	freopen([[NSHomeDirectory() stringByAppendingPathComponent:@"Library/ 
Logs/com.myCompany.MyService.log"] fileSystemRepresentation], "w",  
stderr);	

[pool release];
[MyService sharedApplication];
return [NSApp run];
}
I’m willing to bet that the above is NOT right!

On the whole would it just be easier to add a xib with nothing in it?  
Seems kinda wonky

My gut tells me that this is where I am going wroing!
Steve


On Feb 4, 2009, at 2:37 PM, Peter Ammon wrote:


Hi Steve,

What appears in the Services menu is entirely determined by the  
NSServices portion of your Info.plist.  If you post that to the  
list, we can look for any problems.


Your Service is launched on-demand when the user selects it from the  
menu.  Services may be background only, but do not have to be.


On Tiger and earlier, there is no way to avoid needing to log in and  
out.  On Leopard, you can use the function NSUpdateDynamicServices()  
to immediately scan for new Services.  If you're just testing, a  
quick way to scan for new Services is to run pbs directly:


   /System/Library/CoreServices/pbs

However, pbs has no supported public interface and this will (has  
already) change, so don't include any reference to pbs in a script.   
NSUpdateDynamicServices() is the right way to programmatically  
refresh Services.


-Peter

On Feb 4, 2009, at 7:03 AM, Steve Cronin wrote:

Well, sheesh - that's embarrassing!   There is no 'self' until init  
- I know that!  Ugh.


However, that doesn't change my end result!

I never see anything on the Services menu nor anything from the  
NSLog statements shown below.
(Even when I double-click on the .service file;  after whcih I CAN  
see it in the process list in Activity monitor but still no log  
messages)
Logging out and back in doesn't make my service name appear on the  
Service menu...
This is on a 10.5.6 system using a Release build which has been  
placed in ~/Library/Services.


SO my basic questions still stand:
What event/conditions launches a .service which resides in ~/ 
Library/Services?

Should/must .service files be 'Background Only'?
Am I missing something basic in my setup here -
I have only a Info.plist and 1 .h (NSObject) and 2 . m files (main  
and MyService) and no .xib?
Other than the 'wrapper' settings are there other compiler settings  
required for this setup?
I have only 2 steps in my build process: 'Compile Source (2)' and  
'Link Binary w/ Lib (1)' [Cocoa]





___

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: NSService - I need a headslap (A Solution)

2009-02-05 Thread Steve Cronin

Peter;

Turns out my issue was not related to the Info.plist at all.
The confusion about 'default' label on the 'Services' menu has to do  
with how Finder handles dropping a .plist into .txt field...


My service 'MyService' does indeed need to subclass NSApplication.
I just quit fighting against the tide and added an empty nib. -- Presto!

So now my working stand alone service provider consists of merely 6  
small items:

1) an .icns file
2) an empty IB generated nib file - completely unmodified  (v2 NIB in  
my case [Tiger compatible])
	(adding a NIB allows me to just use the standard main.m  'return  
NSApplicationMain(argc,  (const char **) argv);'

3) main.m  - the usual Cocoa version  (however see question below)
3) an Info.plist (Principal class set to 'MyService' and the standard  
'Services' specification.

4) a MyService.h file which sublclasses NSApplication
5) the MyService.m file for the file above.  This does 3 things:
- in init [NSApp setDelegate:self];
- in 'AppDidFinishLaunch' [NSApp setServiceProvider:self];
- provides the required method(s) for providing a service:
	   - (void) seviceName:(NSPasteboard *)pboard userData:(NSString  
*)userData error:(NSString **)error


*** 2 Questions
-- I am operating on the presumption that this standalone service  
should terminate after providing its service but I can see an argument  
for not doing so.
It's pretty lightweight (one class (~100 lines of ObjC) and an empty  
nib).

Do you have any guidance to offer here.
Since there is no interface to this service, what is the standard UI  
support for termination?


-- In the past, I have used the following main.m to log data to  
specific files:

int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
	freopen([[NSHomeDirectory() stringByAppendingPathComponent:@"Library/ 
Logs/com.mycompany.myapp.log"] fileSystemRepresentation], "w", stderr);	

[pool release];
return NSApplicationMain(argc,  (const char **) argv);
}

But here my log statements are ending up in the console log.
Is there a way I can easily route log statements in MyService to a  
specific file?


Hope to get some feedback on these questions and that this posting  
eventually proves useful to someone else.


Steve


On Feb 4, 2009, at 5:10 PM, Peter Ammon wrote:



On Feb 4, 2009, at 1:23 PM, Steve Cronin wrote:


NSMenuItem

Menu item title
MyService



The key here needs to be "default" instead of "Menu item title".

This is a dictionary because it used to be keyed by localization,  
with "default" the value for an unknown loc.  Now we use the  
ServicesMenu.strings file for localization, but the dictionary  
remains.


-Peter



___

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


Warning 'could not find object file' on NSAppleScript -executeAndReturnError

2009-02-06 Thread Steve Cronin

Folks;

I use AppleScript to accomplish some inter-application tasks.

Over time I have a developed several utility routines in Cocoa, one of  
which is to return the results of an arbitrary script execution. as an  
NSString:


- (NSString *) getStringResutlFromAppleScript:(NSString *)theScript {
NSDictionary *errorDict = nil;
	NSAppleScript *appleScriptObject = [[NSAppleScript alloc]  
initWithSource:theScript];	
	NSAppleEventDescriptor *eventDescriptor = [appleScriptObject  
executeAndReturnError: &errorDict];  \\this compiles on-the-fly if  
necessary

[appleScriptObject release];
if (([eventDescriptor descriptorType]) && (errorDict==nil)) {
return [self stringFromAppleEventDescriptor:eventDescriptor];
} else {
NSLog(@"ERROR: ",theScript);
...

This has been working for quite some time.

But now I have recently noticed that every execution of the  
'executeAndReturnError:' is causing a entry in the console:
warning: Could not find object file "/Developer/usr/lib/gcc/i686-apple- 
darwin9/4.0.1/libgcc.a(_eprintf.o)" - no debug information available  
for "/var/tmp/gcc/gcc-5465~16/src/gcc/libgcc2.c".


I've stepped thru numerous examples and it is ALWAYS this line.  The  
scripts are all valid scripts.

The code executes properly but it just sticks in my craw...
What have a not got configured correctly?

Thanks!
Steve
___

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


NSToolbarItems - deallocating view-based items

2009-02-09 Thread Steve Cronin

Folks;

I have a mix of view and image based toolbar items.
The views are all IBOutlets defined in IB.
Everything is working well - events are handled and items  
arevalidated, everything is dandy.


Except when the user customizes the toolbar.

The image based items can be added and removed 'till the cows come home
BUT the view based items   -  not so much...
They can be added and then they can be removed.
But once they are removed they cannot be re-added unless the  
application is quit and restarted.
Attempting to re-add a view-based toolbar item that has been removed  
causes a message like the following:
" -[NSSearchField retain]: message sent to deallocated instance  
0x19b83490 "



Sooo what is the correct way to handle this?
I guess I'm puzzled by the IBOutlet aspect..


___

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: NSToolbarItems - deallocating view-based items

2009-02-10 Thread Steve Cronin

Peter;

Thanks for the reply but
.
The documentation for NSToolbarItem for =setView says:
"...The view for the receiver. The view and all of its contents must  
conform to the NSCoding protocol if the toolbar supports  
customization"

There is no further discussion in the documentation.

One of the my view based items is just a simple NSSearchField.   
NSSearchfield DOES conform to NSCoding.
Is it clarified anywhere in the documentation what else is necessary  
to successfully customize a view based toolbar item?


I have declared the instance variable as an IBOutlet:
IBOutlet NSSearchField *searchFieldOutlet;
(I need the IBOutlets to fully utilize the toolbar item. functionality  
in my controller code)

I have hooked this up in the usual way inside IB.

I just do not understand what you mean by "fresh".
Are you saying that I must instantiate them in code?  ([... alloc]  
init])

How do I hook this code instance as an IBOutlet?
Do I release after the "- 
itemForItemIdentifier:willBeInsertedIntoToolbar:" method


I have more complex views than a single NSSearchField, how do I deal  
with them?
Is the end result that you cannot use IB built view based toolbar  
items if you intend to allow customization;  that you must build the  
entire view in code?


Could you explain just a bit more?
Steve







On Feb 10, 2009, at 5:47 PM, Peter Ammon wrote:



On Feb 9, 2009, at 7:13 PM, Steve Cronin wrote:


Folks;

I have a mix of view and image based toolbar items.
The views are all IBOutlets defined in IB.
Everything is working well - events are handled and items  
arevalidated, everything is dandy.


Except when the user customizes the toolbar.

The image based items can be added and removed 'till the cows come  
home

BUT the view based items   -  not so much...
They can be added and then they can be removed.
But once they are removed they cannot be re-added unless the  
application is quit and restarted.
Attempting to re-add a view-based toolbar item that has been  
removed causes a message like the following:
" -[NSSearchField retain]: message sent to deallocated instance  
0x19b83490 "



Sooo what is the correct way to handle this?
I guess I'm puzzled by the IBOutlet aspect..


Hi Steve,

Make sure that your implementation of  
toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar: returns a  
toolbar item with a "fresh" view each time.  That should take care  
of this problem.


-Peter



___

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


Cocoa <- > PHP <-> MySQL

2009-03-03 Thread Steve Cronin

Folks;

I've inherited some Cocoa code that uses NSMutableNURLRequest and  
NSURLConnection to pass .php request to a server.
The NSMutableURLRequest packs up some data into the the .php which  
stuffs this data into a MySQL database.


This is all working nicely.

Now what I've been asked to make happen is to submit a different bit  
of php which will run a query against this same MySQL database.
We want to use Cocoa to submit the php script and retrieve the  
response, which will be the results of the query.


Setting aside the php on the server side, I'm hoping to find a working  
example of something similar to the Cocoa piece of this new requirement.


I'm just looking for how to 'submit', wait for response,  capture the  
response / error in Cocoa.

I'll get the server side figured out separately

Thanks for any pointers!
Steve
___

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


NSTextView won't allow a Return (Enter)

2009-03-07 Thread Steve Cronin

Folks;

I'm really puzzled by this one.  In one window I have a TexView inside  
a ScrollView - works well - user can type many lines and scroller  
appear and disappear as expected.


In another window I have another TextView inside a ScrollView and  
every time the user hits the 'Return' or 'Enter' I get what is shown  
below.

What is making the TextView give up being first responder?
I can't see any difference in the IB settings...

The 'offending' textView accepts the cursor normally and as long as  
the user does not use the 'Enter/Return' all is well.
When that key is struck then the cursor disappears.  A set of 'Tab's  
will bring the cursor back cycling through the various fields on the  
window.
I know this is probably one of those 'Duh' issues but I evidently need  
the whack on the head to see it


Thanks for the tap,
Steve


#2  0x90837e94 in _NSSetObjectValueAndNotify
#3  0x907d9cee in -[NSObject(NSKeyValueCoding) setValue:forKey:]
#4  0x9085e7c1 in -[NSObject(NSKeyValueCoding) setValue:forKeyPath:]
#5	0x9194c441 in -[NSBinder  
_setValue:forKeyPath:ofObject:mode:validateImmediately:raisesForNotApplicableKeys:error 
:]

#6  0x9194c1f2 in -[NSBinder setValue:forBinding:error:]
#7	0x9194be8b in -[NSValueBinder  
_applyObjectValue:forBinding:canRecoverFromErrors:handleErrors:typeOfAlert:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert 
:]
#8	0x9194bb19 in -[NSValueBinder  
applyDisplayedValueHandleErrors:typeOfAlert:canRecoverFromErrors:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert 
:]
#9	0x9194e86e in -[NSValueBinder  
_applyDisplayedValueIfHasUncommittedChangesWithHandleErrors:typeOfAlert:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert 
:]
#10	0x9194b3fa in -[NSValueBinder  
validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled 
:]
#11	0x9194b1b7 in -[_NSBindingAdaptor  
_validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled:bindingAdaptor 
:]
#12	0x9194b0ef in -[_NSBindingAdaptor  
validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled 
:]

#13 0x9181da6d in -[NSTextView(NSSharing) resignFirstResponder]
#14 0x91793b0d in -[NSWindow makeFirstResponder:]
#15 0x9181d628 in -[NSTextView(NSPrivate) _giveUpFirstResponder:]
#16 0x9181d4df in -[NSTextView(NSKeyBindingCommands) insertNewline:]
#17 0x9181d281 in -[NSResponder doCommandBySelector:]
#18 0x9181d108 in -[NSTextView doCommandBySelector:]
#19	0x91810229 in - 
[NSKeyBindingManager(NSKeyBindingManager_MultiClients)  
interpretEventAsCommand:forClient:]

#20 0x9180ee36 in -[NSTSMInputContext interpretKeyEvents:]
#21 0x9180e952 in -[NSView interpretKeyEvents:]
#22 0x9180e862 in -[NSTextView keyDown:]
#23 0x9177eddd in -[NSWindow sendEvent:]
#24 0x9174ad49 in -[NSApplication sendEvent:]
#25 0x916a869f in -[NSApplication run]
#26 0x916758a4 in NSApplicationMain

___

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: NSTextView won't allow a Return (Enter)

2009-03-07 Thread Steve Cronin

Folks;

Sheepish - the offending textView was set as field Editor

Yeesh I guess I need some sleep.

Thanks for the responses!
Steve


On Mar 8, 2009, at 12:02 AM, Scott Anguish wrote:


what bindings have you set for the misbehaving text view?


On 8-Mar-09, at 12:41 AM, Steve Cronin wrote:


What is making the TextView give up being first responder?




___

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


Double Initialize - is that how it should be?

2009-03-16 Thread Steve Cronin

Folks;

I use an object in my application called 'appDelegate'; it's a  
subclass of NSObject.


I instantiate this object in the main Nib file
This object has  IBActions for the main menu and since it is -app  
delegate it is a kind on central dispatcher.


My question is this:
The +initialize is run twice when the app loads:
2009-03-16 20:21:42.690 XYZ[6676:813] *[AppDelegate initialize]
2009-03-16 20:21:42.781 XYZ[6676:813] *[NSKVONotifying_AppDelegate  
initialize]


Once for the object itself and then again as the instance in the Nib.   
That's how I read this.  Is that wrong?


So I wonder if this is wasteful.  I don't really want to run  
initialize twice.
It kind of torques my notion of a class that +initialize is run twice  
but I try and just play along
I don't see how to use this IBActions and IBOutlets without  
instantiating.

Is the correct thing to do here break this object into smaller objects?

Thanks for any clarifying comments
Steve

+initialize {
//check minimum system OS - so I can gracefully tell the user what is  
deal is and how they should upgrade - if not min then die
//check whether or not the app has access to the ~/Library/Application  
Support - if not then die

//test for keyDown - to flip the logging level
}

- init {
//set this object as app delegate
[[NSApplication sharedApplication] setDelegate:self];
//NSFormatters and NSValueTransformers which must be done here so  
awakeFromNib binding transformers are set

[self setupApplicationBehavior];
//hang onto the prefPath
prefFile = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,  
NSUserDomainMask, YES) objectAtIndex:0]  
stringByAppendingPathComponent:@"Preferences"]  
stringByAppendingPathComponent:NSBundle mainBundle]  
infoDictionary] valueForKey:@"CFBundleIdentifier"]   
stringByAppendingString:@".plist"]] retain];

//determine if this is the first time prefs have been used
firstPrefUse = (![[NSFileManager defaultManager]  
fileExistsAtPath:prefFile]);

//load userPrefs here so they can be used by -awakeFromNib
userDefaults = [[NSUserDefaults standardUserDefaults] retain];
[self registerFactoryDefaults];
return self;
)



___

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


What is the console trying to tell me?

2009-03-19 Thread Steve Cronin

Folks;

I have an 10.5 Intel development environment but I am deploying to  
10.4 Universal using the 10.4 SDK.


I have  a QTMovieView object from IB in a window.
When I run in Debug mode a message appears in the Console.
When I run in Release mode on either platform - no message appears (I  
route stderr to a logfile)


Everything works fine, Debug and Release;  I would just like to know  
what I am trying to be told!


Here's the gist of the message:
shlibs-removed,shlib-info=[num="103",name="AudioIPCPlugIn"
shlibs-removed,shlib-info=[num="104",name="AppleHDAHALPlugIn"

Thanks!
Steve

___

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   >