Hi all,
Got another n00b question for you... You've been great about answering my questions so far! Thanks!
I'm wondering if I need to explicitly call release on arrays returned from methods in the collection classes. For example, I'd like to know if a key already exists for an instance of NSMutableDictionary. In .NET, the Dictionary class has a handy KeyExists(string) method which unfortunately NSMutableDictionary does not have. What I can do, however, is iterate over the collection returned by NSMutableDictionary's allKeys method. The documentation for this method states "A new array containing the receivers keys, or an empty array if the receiver has no entries." [emphasis added by me].
My question is whether or not I need to explicitly call release on the array returned by this once I'm done searching for a key in the array. EG:
First question, will containsObject find it if they're not the exact same reference? And will calling release cause me a whole bushel of problems?
Thanks again guys!
Got another n00b question for you... You've been great about answering my questions so far! Thanks!
I'm wondering if I need to explicitly call release on arrays returned from methods in the collection classes. For example, I'd like to know if a key already exists for an instance of NSMutableDictionary. In .NET, the Dictionary class has a handy KeyExists(string) method which unfortunately NSMutableDictionary does not have. What I can do, however, is iterate over the collection returned by NSMutableDictionary's allKeys method. The documentation for this method states "A new array containing the receivers keys, or an empty array if the receiver has no entries." [emphasis added by me].
My question is whether or not I need to explicitly call release on the array returned by this once I'm done searching for a key in the array. EG:
Code:
- (BOOL)keyExists:(id)key {
BOOL keyExists = NO;
NSArray *keys = [dictionary allKeys];
keyExists = [keys containsObject:key];
[keys release];
return keyExists;
}
First question, will containsObject find it if they're not the exact same reference? And will calling release cause me a whole bushel of problems?
Thanks again guys!