Re: Dictionary? Array? or other
Re: Dictionary? Array? or other
- Subject: Re: Dictionary? Array? or other
- From: "Dirk van Oosterbosch, IR labs" <email@hidden>
- Date: Sat, 3 Sep 2005 18:05:42 +0200
On 3-sep-05, at 17:28, Aaron Wallis wrote:
the source for tempExpression is:
// Create a expression object to relate to its properties
expressionEntry * tempExpression = [[ expressionEntry alloc ]
init];
[tempExpression setSeperator : splitStringBy ];
[tempExpression setResult : splitStringResult ];
where expressionEntry is a class I have written.
And there is a [tempExpression release] a few lines down...
expressionsItems is declared in the header file, as its pretty much a
global variable...
and when I NSLog it I get null....
You also need to define the dictionary (in your implementation)
NSMutableDictionary * expressionsItems = [[NSMutableDictionary alloc]
init];
or
NSMutableDictionary * expressionsItems = [NSMutableDictionary
dictionary]; // This makes it autoreleased
I found the concept of global variables not so applicable in a true OO
environment like Objective-C / Cocoa, as it would in rather more
scripting languages. With Objective-C/Cocoa I only use global variables
–with the extern keyword– to declare NSStrings that act as keys for the
notificationCenter or the userDefaults. In the case of your example
there needs to be an object in the end that holds the collection (or in
the case of a FoundationTool just main.m). Then the expressionsItems is
just an ivar of that object.
d.
-----------------------------
Dirk van Oosterbosch
de Wittenstraat 225
1052 AT Amsterdam
the Netherlands
http://labs.ixopusada.com
-----------------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden