Reputation: 1691
Have a function in tableview.m which gets me the start date and I add the strings in an array. now I want to pass this array to another method in different .m class called listview.m to retrieve the value in nsstring from the array. How should I go about it? Any help is really appreciated.
- (id) getDate: (NSMutableArray *) classStart{
if ([self init]) {
if (sqlite3_open([dbPath UTF8String], &db) == SQLITE_OK) {
self.listArray = [[[NSMutableArray alloc] init] autorelease];
const char *query_stmt = "select start_Date from test order by start_Date";
if (sqlite3_prepare_v2(db, query_stmt, -1, &statement, NULL) == SQLITE_OK)
{
while(sqlite3_step(statement) == SQLITE_ROW)
{
start_Date = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement,0)];
[self.listArray addObject:start_Date];
}
sqlite3_finalize(statement);
sqlite3_close(db);
}
}
}
return self;
}
Upvotes: 0
Views: 910
Reputation: 5266
I don't think there is any magic to this, just define a method in listview.m that will take the array as input.
Your definition in the listview.h might look like:
-(void)addListArray:(NSArray *)theArray;
Then from your class above you'd call it like:
[myListView addListArray:self.listArray];
Upvotes: 1
Reputation: 1691
Figured out : Just changed the function header to
- (NSMutableArray *) getDate {
return array;
}
And call the method as array_two = [ListView getDate]; in the other class.
Both arrays are nsmutablearrays.
Upvotes: 0