Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
iOS Development
when should release be called
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Mark FX" data-source="post: 1409713" data-attributes="member: 211556"><p>Like your last post, your making some very basic errors in Objective-C, and syntax, and also eliminating some important parts of the code.</p><p></p><p>Your if statements are checking if an NSString, and a NSDictionary are NULL, neither the NSString or NSDictionary classes can be a value of NULL, but they can be a value of nil.</p><p></p><p>The NULL value applies to C and Java, but not Objective-C classes.</p><p></p><p>Your question about releasing objects is a good one, but is not a straightforward one, and can vary a great deal to different classes, for example if you add an Objective-C variable to ann NSArray, you can release that variable as soon as its added to the array, because the array holds a pointer to it, this is the same as UIView classes, they also can be released as soon as they are added to a super view, as the super view retains it.</p><p></p><p>In short, you can release an object as soon as your finished with it, which is an over simplified explaination, but this can vary with so many different factors.</p><p></p><p>I can only advise you to check out the book recommendation I made in your last post, also you might consider using ARC for your projects, this will eliminate the need for you to release your variables manually, or alternatively consider using autoreleased variables more frequently in your code, for the same reasons.</p><p></p><p>Good Luck with it.</p><p></p><p>Regards Mark</p></blockquote><p></p>
[QUOTE="Mark FX, post: 1409713, member: 211556"] Like your last post, your making some very basic errors in Objective-C, and syntax, and also eliminating some important parts of the code. Your if statements are checking if an NSString, and a NSDictionary are NULL, neither the NSString or NSDictionary classes can be a value of NULL, but they can be a value of nil. The NULL value applies to C and Java, but not Objective-C classes. Your question about releasing objects is a good one, but is not a straightforward one, and can vary a great deal to different classes, for example if you add an Objective-C variable to ann NSArray, you can release that variable as soon as its added to the array, because the array holds a pointer to it, this is the same as UIView classes, they also can be released as soon as they are added to a super view, as the super view retains it. In short, you can release an object as soon as your finished with it, which is an over simplified explaination, but this can vary with so many different factors. I can only advise you to check out the book recommendation I made in your last post, also you might consider using ARC for your projects, this will eliminate the need for you to release your variables manually, or alternatively consider using autoreleased variables more frequently in your code, for the same reasons. Good Luck with it. Regards Mark [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
iOS Development
when should release be called
Top