Get my custom object from NSDictionary variable
Get my custom object from NSDictionary variable
- Subject: Get my custom object from NSDictionary variable
- From: Daniel Káčer <email@hidden>
- Date: Fri, 5 Mar 2010 00:48:05 +0100
Hi,
i solve the following problem:
a add my custom object into NSDictionary variable in my application
with following code:
[myDictionary setObject:[[ComplexObject alloc] initWithFrom:_tempFrom
pairTo:string] forKey:[NSString stringWithFormat:@"%d", [myDictionary
count]]];
.. it seems, that this work correctly ..
but .. when i will retrieve value from my custom object from this
NSDictionary variable, there is some issue ... and i don't know, what
i do wrongly in this case ...
int iRandom = arc4random() % ([myDictionary count] - 1);
ComplexObject* compObj = [myDictionary objectForKey:[NSString
stringWithFormat:@"%d", iRandom]];
NSString* sText = [compObj valueFrom]; <--- on this line is some issue
-------------------------------------
This is interface of my custom object:
@interface ComplexObject : NSObject
NSString* sValueFrom;
NSString* sValueTo;
-(ComplexObject*) initWithFrom:(NSString*)_sValueFrom pairTo:
(NSString*)_sValueTo;
-(NSString*) valueFrom;
-(NSString*) valueTo;
@end
and this is implementatio of my custom object:
@implementation ComplexObject
- (NSString*) valueFrom {
return sValueFrom;
}
- (NSString*) valueTo {
return sValueTo;
}
- (ComplexObject*)initWithFrom:(NSString*)_sValueFrom pairTo:
(NSString*)_sValueTo {
self = [super init];
if (self) {
sValueFrom = _sValueFrom;
sValueTo = _sValueTo;
}
return self;
}
@end
_______________________________________________
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