Re: NSURLConnection crashes with EXC_BAD_ADDRESS -- can't find why...
Re: NSURLConnection crashes with EXC_BAD_ADDRESS -- can't find why...
- Subject: Re: NSURLConnection crashes with EXC_BAD_ADDRESS -- can't find why...
- From: david paeme <email@hidden>
- Date: Fri, 10 Apr 2009 09:54:58 +0200
On 10 Apr 2009, at 02:21, Greg Guerin wrote:
david paeme wrote:
instead of a string (%@) the
%@ is the code for the -description of an object. Strictly
speaking, that isn't merely a string, but the result of sending a
message.
UInt lastupdate = [userDefaults integerForKey:@"lastDBUpdate"];
NSString *urlString = [NSString stringWithFormat:@"%@?act=upd&lu=
%d",WS_URL,lastUpdated];
Either you have typos, or that isn't doing what you think it's
doing. The UInt is named "lastupdate", but the arg to
stringWithFormat: is named "lastUpdated". Note the difference in
case for 'U' and the presence of 'd' for the latter.
Ah, don't worry, that's just a typo in the email -- the lastUpdate
assignment happens in a test a bit earlier in the code, i just typed
the assignment in here, without taking too much care. The correct
version of code above works fine :-)
but:
the old crashing scenario:
NSString *lastUpdated = [NSString stringWithString:@"0"]; -- used as
%@ (not literally this code of course, but equivalent)
working scenario:
UInt lastUpdated = 0; -- used as %d
What's the difference when I do the stringWithFormat to make the
urlString? The stuff that ends up in the urlString/urlRequest is the
same when I NSLog it...
i still have no idea why that solved the problem - my hunch would
be the string parsing in the NSURLConnection - as both strings
should be quite equal, no?
You could NSLog the text, generated both ways, and probably confirm
or refute the hunch. Evidence is better than hunches, especially
when it's easy to get.
did that a million times over the time it crashed - printed out the
string, urlstring, urlrequest, ... all printed out the same thing -
with an &lu=0 at the end of the url (as it should be).
and then in the trace, you see that the wheels come off the bike
somewhere deep in the NSURLConnection code...
-- GG
_______________________________________________
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
_______________________________________________
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