On Fri, Apr 10, 2009 at 3:54 AM, david paeme <dvdpm.co...@gmail.com> wrote: > > 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 :-)
Always copy/paste code you need help with, because we can't tell whether a mistake is actually causing your problem or is just due to retyping it. > 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... Absolutely none. Both should work equally well. Typically when this sort of thing happens, where two pieces of code that SHOULD produce identical results don't, it's indicative of another more subtle bug elsewhere in your program, like a memory management error, a memory smasher, or something equally unsavory. Basically, when you change your code from one "equivalent" form to another, you're changing how things are done internally enough to trigger or mask the bug found elsewhere. Given your crash, I'd first suggest enabling zombies and see if they find anything. If that doesn't help, perhaps guard malloc or another memory debugger will do it for you. The Clang static analyzer can also be very helpful for finding problems in your code. Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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