Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
for(NSString *str in arr) { NSLog(@\"string: %@\", str ); }
[arr release]; }
There is a strong convention in Cocoa programming that methods like this should return an autoreleased object, and the caller should retain it if they want to keep it.
If you want to return a retained object, have the name begin with "new".
In fact, the LLVM compiler uses this naming convention when it does code analysis. It expects methods to return autoreleased objects unless their names begins with new, alloc, copy, or mutableCopy. Methods who's names DO start with new, alloc, copy, or mutableCopy are expected to return retained object.
This is a really, really good idea to follow. When you follow that rule, it's obvious what you need to do with any given object.
Regards,
Duncan C WareTo
Animated GIF created with Face Dancer, available for free in the app store.
There is a strong convention in Cocoa programming that methods like this should return an autoreleased object, and the caller should retain it if they want to keep it.
If you want to return a retained object, have the name begin with "new".
In fact, the LLVM compiler uses this naming convention when it does code analysis. It expects methods to return autoreleased objects unless their names begins with new, alloc, copy, or mutableCopy. Methods who's names DO start with new, alloc, copy, or mutableCopy are expected to return retained object.
This is a really, really good idea to follow. When you follow that rule, it's obvious what you need to do with any given object.
Thanks, that's exactly what I want to do. Return a retained object, but not an autorelease object.
Hopefully, returning a retained object does not automatically make it an autorelease object behind the scenes?
I replaced:
getArray
with:
newArray
And the compiler warning message went away. I didn't know that was possible.
Replies
SlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeIf you want to return a retained object, have the name begin with "new".
In fact, the LLVM compiler uses this naming convention when it does code analysis. It expects methods to return autoreleased objects unless their names begins with new, alloc, copy, or mutableCopy. Methods who's names DO start with new, alloc, copy, or mutableCopy are expected to return retained object.
This is a really, really good idea to follow. When you follow that rule, it's obvious what you need to do with any given object.
Duncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeHopefully, returning a retained object does not automatically make it an autorelease object
behind the scenes?
I replaced:
with:
And the compiler warning message went away. I didn't know that was possible.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome