0

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;
}

2 Answers 2

1

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];
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.