• 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: Regarding MVC design pattern
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regarding MVC design pattern


  • Subject: Re: Regarding MVC design pattern
  • From: Kyle Sluder <email@hidden>
  • Date: Tue, 18 May 2010 09:24:57 -0700

On May 18, 2010, at 4:20 AM, Sai <email@hidden> wrote:

Hi all,

Thanks for your reply. I didn't retain that, I will try that as soon as I
get home.
Anyway, why I should retain that? Will it be released by "somebody"?

Re-read the Memory Management Programming Guide until you know the rules backwards and forwards. +dictionaryWithObjects:forKeys: doesn't start with "alloc," "new," or "copy," so you don't own its return value.


Can
anyone tell me the whole process and what's going on please? I want to know
what happened. Thanks a lot.

This shouldnt be necessary once you reread the documentation. But in order to do that, you would need to post your code in context, which you should always do for every question you ask. Out of context, what you posted is neither wrong nor right.


--Kyle Sluder



On Tue, May 18, 2010 at 7:07 PM, Jack Nutting <email@hidden> wrote:


On Tue, May 18, 2010 at 12:40 PM, Sai <email@hidden> wrote:
However, I declare a NSDictionary instance variable in my model object.
This
NSDictionary instance
store some data I need. And I will create this NSDictionary instance by
invoking:
[NSDictionary dictionaryWithObjects:names forKeys:keys]

Are you retaining that?

- (id)init {
if (self = [super init]) {
// assuming you have an ivar called "dict", this will lead to the
problem you define:
dict = [NSDictionary dictionaryWithObjects:names forKeys:keys];
// but this should work:
dict = [[NSDictionary dictionaryWithObjects:names forKeys:keys] retain];
}
}


--
// jack
// http://nuthole.com
// http://learncocoa.org

_______________________________________________

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
_______________________________________________

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


  • Follow-Ups:
    • Re: Regarding MVC design pattern
      • From: Sai <email@hidden>
References: 
 >Regarding MVC design pattern (From: Sai <email@hidden>)
 >Re: Regarding MVC design pattern (From: Henry McGilton <email@hidden>)
 >Re: Regarding MVC design pattern (From: Sai <email@hidden>)
 >Re: Regarding MVC design pattern (From: Jack Nutting <email@hidden>)
 >Re: Regarding MVC design pattern (From: Sai <email@hidden>)

  • Prev by Date: Re: Programmatic Binding
  • Next by Date: Re: Why I can't see my localized nib?
  • Previous by thread: Re: Regarding MVC design pattern
  • Next by thread: Re: Regarding MVC design pattern
  • Index(es):
    • Date
    • Thread