Reputation: 5020
I have created a new NSObject
class as below:
@interface LoginObject : NSObject {
NSString *fName;
NSString *lName;
NSString *sessionId;
NSString *result;
NSString *response;
}
Now I can create an object of this type as:
LoginObject *login;
What do i need to do in order to create an NSMutableArray
of my own NSObject
class.
can any body guide? Thanks
Upvotes: 0
Views: 2083
Reputation:
First create objects of your class,an array as -
LoginObject *obj1 = [[LoginObject alloc]init];
obj1.fName = @"xxxx";
-----------
LoginObject *obj1 = [[LoginObject alloc]init];
obj1.fName = @"xxxx";
-----------
// create a array with above objects
// nil indicate end of array
NSMutableArray *users = [[NSMutableArray alloc]initWithObjects:obj1,obj2,...,nil];
//if you want you can add other objects too -
[users addObject:obj10];
Upvotes: 0
Reputation: 555
Just have a look at the NSMutableArray
documentation here - http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/Reference/Reference.html
Use one of the init or array methods.
arrayWithObjects
is the one I use most often.
Upvotes: 1
Reputation: 11839
In Which class you want to have this array, you can create-
@property (nonatomic, retain) NSMutableArray *loginObjectArray;
in implementation file-
LoginObject *myLoginObject = [[LoginObject alloc] init];
myLoginObject.fName = ---
......
[loginObjectArray addObject:myLoginObject];
....
Don't forget to initialize loginObjectArray.
Upvotes: 0