• 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
PLEASE IGNORE...INCORRECT LIST APPOLOGIES
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PLEASE IGNORE...INCORRECT LIST APPOLOGIES


  • Subject: PLEASE IGNORE...INCORRECT LIST APPOLOGIES
  • From: Michael de Haan <email@hidden>
  • Date: Thu, 22 Oct 2009 18:26:18 -0700


Let me start by saying I **think** I understand why my first approach did not work, but am interested if my working approach is correct in concept.

Background.
As a **very long** detour from Hillegass's chapter 18 challenge, I am following along with mmalc's excellent series of Binding examples. Thus, now creating a table of 4 columns without bindings. (He uses 1 column, but I added a few).


In order to create the NSMutableDictionary object, which will be added to an NSDoc Array ivar, (which will be used by the datasource methods of a table) I have created a 
     
Record Object with one ivar (  _record ( An NSMutableDictionary).)

which returns:

First approach: ( did **not** work)

-(id) init
{
      self = ....snip...usual code
       NSString * _name = @"John Doe"; 
       NSString *  _city
       ....snip...other string properties


      _record = [ NSMutableDictionary dictionaryWithObjectsAndKeys:
       _name, MDHNameKey,
       ....snip...
      nil;
    }
  return self;
}


As I learnt, self returns an empty object. ( If I understand it correctly, the local variables _name etc are no longer in scope once self is returned.)


Second approach.

Record Object with 4 ivars viz
_name
_city etc etc


Self now returns an object whose attributes are now, in the calling method ( the "AddRecord")  used to create the NSMutableDictionary object and added  "model" array, and the table populates as expected.


May I ask if this is the correct approach? ...or should one still try and aim to **return** a dictionary object to the calling method?

Thanks as always, in advance.







 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: The "correct" approach? Question about creating an NSMutableDictionary instance.
  • Next by Date: Re: The "correct" approach? Question about creating an NSMutableDictionary instance. PLEASE IGNORE...SENT TO THE WRONG LIST
  • Previous by thread: Re: The "correct" approach? Question about creating an NSMutableDictionary instance. PLEASE IGNORE...SENT TO THE WRONG LIST
  • Next by thread: Validating a form
  • Index(es):
    • Date
    • Thread