I want to create a key value pair like NSDictionary but as it is not Sorted
am usiing a class for it....
my question is wher shld i deallocate KeyValue kvObj in my code????
This will surely create mem leaks.....plz suggest
KeyValue.h
Dictionary.m
am usiing a class for it....
my question is wher shld i deallocate KeyValue kvObj in my code????
This will surely create mem leaks.....plz suggest
KeyValue.h
Code:
@interface KeyValue : NSObject {
NSString *_key;
NSString *_value;
}
@property(nonatomic,retain)NSString *_key;
@property(nonatomic,retain)NSString *_value;
@end
Dictionary.m
Code:
#import KeyValue
@implementation Dictionary
static NSMutableArray *arryColor;
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSString *responseString = [request responseString];
NSArray *arry;
arry= [responseString componentsSeparatedByString:@","];
for (int i=0; i<[arry count]; i++) {
NSArray *arryValue = [[arry objectAtIndex:i] componentsSeparatedByString:@"~"];
// arryValue = 1~abc,2~xyz,3~pqr;
[COLOR="red"]KeyValue kvObj= [[KeyValue alloc] init];[/COLOR]
kvObj._key=[arryValue objectAtIndex:0]; //key like 1,2,3,...
kvObj._value=[arryValue objectAtIndex:1]; //value like abc,xyz,pqr....
[COLOR="Red"][arryColor addObject:kvObj];[/COLOR]
}
}