On Tue, Jun 23, 2009 at 12:31 AM, WT<jrca...@gmail.com> wrote: > What the heck??? > > So, after I scratched my head silly for several minutes, it suddenly came to > me. If I'm going to use a property, I *must* refer to it as object.property > rather than simply as property. In the specific example I had, I should not > have replaced all those repeated chunks of code with > > textFieldPreviousContent = textField.text; > > but with > > self.textFieldPreviousContent = textField.text; > > Using > > textFieldPreviousContent = textField.text; > > meant that I was bypassing the very memory management I thought I was > getting for free by turning textFieldPreviousContent into a property. Of > course, my mistake implied that a) I was leaking the string pointed to by > textFieldPreviousContent and b) I was not retaining the string returned by > textField.text. And since that string is returned to me auto-released, > textFieldPreviousContent ended up pointing to a memory location that was no > longer valid by the time I used its contents. No wonder my app crashed.
Stuff like this is why I believe this silly dot syntax thing should be avoided completely. If you had written [self setTextFieldPreviousContent:[textField text]], not only would you have avoided the mysterious crash, but it's *much* clearer exactly what's going on. Using dot syntax instead of brackets only saves you maybe four characters of typing and costs you dearly in terms of clarity. 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