Reputation: 651
I have this class:
@interface Item : NSObject {
NSString *name;
NSString *description;
}
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *description;
+ (id)ItemWithDescription:(NSString*)description name:(NSString*)name;
And I am using the following mutable array to keep a complete list of all the items:
@property (strong,nonatomic) NSMutableArray *ItemArray;
With the code below, in the .m file, I insert a new element in the array
[self.ItemArray addObject: [Item ItemWithDescription: @“aDescription” name: @“aName”]];
Till here all is ok, but the problem now is that I don’t know how to extract the element “description
” (as a NSString) of a desired item in the array (let’s say at position [0]). Anyone knows the right syntax to be used?
Upvotes: 0
Views: 48
Reputation: 17860
Item *item = (Item *)self.ItemArray[0];
NSLog(@"%@", item.description);
Upvotes: 1