Re: Totally stumped on extern NSString
Re: Totally stumped on extern NSString
- Subject: Re: Totally stumped on extern NSString
- From: Fritz Anderson <email@hidden>
- Date: Sat, 7 Jul 2007 20:25:51 -0500
On 7 Jul 2007, at 6:45 PM, William Squires wrote:
- (void)writeToFile:(NSString *) path
{
...
}
+ (void)writeSharedAddressBookToFile
{
// Added as a debug aid..
NSString *localStr = [NSString stringWithString:AddressBookFilePath];
// ...
[[AddressBook sharedAddressBook] writeToFile:localStr];
}
...
@end
(uninteresting parts trimmed for brevity... :) )
...
[The -writeToFile: method fails...]
because path = nil, but when I click on the stack crawl to view the
calling method, I can see (in the Globals Browser) that
AddressBookFilePath is initialized and has a valid NSString in it!
Why is the call losing the NSString pointer value?
If your "interesting parts" demonstrate that there is no bug, and you
have a bug, then something is going on in the parts you think are
uninteresting. For instance, your excerpts never show
AddressBookFilePath being initialized.
I'd break at the first line of -writeSharedAddressBookToFile and try a
print-object on AddressBookFilePath (enter 'po AddressBookFilePath' in
the debugger console). If it's nil, then you've learned something.
I'd do a global find on AddressBookFilePath, to verify that it is
defined only once. I would put a breakpoint on every assignment to
AddressBookFilePath, to see the last value it was given.
(You are gate-keeping AddressBookFilePath with accessor methods,
aren't you? If so, why are you making the variable globally-accessible?)
I know I'm asking you to do things for which you feel you already know
the answers, but if everything is going as you think it should, then
you don't have a bug.
— F
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden