• 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
Get my custom object from NSDictionary variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Get my custom object from NSDictionary variable
      • From: Alexander Spohr <email@hidden>
    • Re: Get my custom object from NSDictionary variable
      • From: Graham Cox <email@hidden>
  • Prev by Date: Converting a Cocoa Application project to a document-based one
  • Next by Date: Re: Get my custom object from NSDictionary variable
  • Previous by thread: Re: Converting a Cocoa Application project to a document-based one
  • Next by thread: Re: Get my custom object from NSDictionary variable
  • Index(es):
    • Date
    • Thread