开发者

how to display the data from the array

// Take an array to store all string.
NSMutableArray *allRows = [[[NSMutableArray alloc] init] autorelease];

while(sqlite3_step(statement) == SQLITE_ROW)
    {   
        char *field1 = (char *) sqlite3_column_text(statement,0);
        NSString *field1Str = [[NSString alloc] initWithUTF8String: field1];
        char *field2 = (char *) sqlite3_column_text(statement,1);
        NSString *field2Str = [[NSString    alloc] initWithUTF8String: field2];

        NSString *str = [NSString stringWithFormat:@"%@::%@",field1Str, field2Str];
        // textv.text=str; // I don't know why your are mixing your view controller stuff's in database function.
// Add the string in the array.
allRows addObject:str];

        [field1Str release];
开发者_C百科        [field2Str release];
        }

// Finally you can return your allRows
return allRows;

ok now how to display the data from that array


If you want to display in a UITableview means do like this.

 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
    {
    return [allRows count];
    }     


     - (UITableViewCell *)tableView:(UITableView *)tablefirst cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        [allRows objectAtIndex:i];

        }


I think this is thing you want...

for(int i=0;i< allRows.count;i++)
{
[allRows objectAtIndex:i];
}


for (int index=0; index<[allRows count]; index++) {
            NSString *retrievedString=[allRows objectAtIndex:index];
//use retrievedString and display it in label kinda thing
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜