• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Re Re: String variables in classes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re Re: String variables in classes


  • Subject: Re: Re Re: String variables in classes
  • From: Graham Cox <email@hidden>
  • Date: Mon, 3 Jan 2011 11:38:58 +1100

On 03/01/2011, at 10:17 AM, Brian Durocher wrote:

> This line of code seems to work for exactly what I was looking for:
>
>    temp = [[temp stringByAppendingFormat:@" %@ %@ \n", input1, input2]
> retain];


Except it's quite wrong from a memory management point of view.

As well as the excellent advice you've already received, you really must take my advice about not just reading but KNOWING the memory management rules:

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html

C++, with which you're familiar, has no built-in memory management except allocation and free. You have to track those allocations yourself if you are to prevent leaks and so on. In Cocoa, this tracking is about 80% handled for you provided you follow the rules. The rules are there to ensure that the tracking works. (Or you can enable garbage collection and then the tracking is 100% handled for you).

> although I have to admit I am unsure really what the "retain" will
> actually do here with respect to memory.

Which means you haven't read the rules, let alone committed them to heart. I urge you to do so before progressing further.

--Graham


_______________________________________________

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

References: 
 >Re Re: String variables in classes (From: Brian Durocher <email@hidden>)

  • Prev by Date: Re: Re Re: String variables in classes
  • Next by Date: Re: UITableViewCell showsReorderControl does nothing
  • Previous by thread: Re: Re Re: String variables in classes
  • Next by thread: Re: Search within a UIWebView (iOS 4.2)
  • Index(es):
    • Date
    • Thread