I've got a chat app that is based on a navigation controller.
Within the view that displays the conversation i load all the previous history from SQLite within the viewDidLoad method.
When a conversation grows it takes a few seconds to open up the view and therefore feels "laggy".
Below is my code that i use to load the history from the database.
Any ideas what could be improved to make the UI feel more responsive?
NSString *sql = [NSString stringWithFormat:#"SELECT * FROM chatHistory WHERE channelID = '%#' ORDER BY time ASC", box.activeChannel];
sqlite3_stmt *statement;
if(sqlite3_prepare_v2([box db], [sql UTF8String], -1, &statement, nil) == SQLITE_OK) {
while(sqlite3_step(statement) == SQLITE_ROW) {
char *field1 = (char *) sqlite3_column_text(statement, 0);
NSString *channelID = [[NSString alloc] initWithUTF8String:field1];
char *field2 = (char *) sqlite3_column_text(statement, 1);
NSString *sender = [[NSString alloc] initWithUTF8String:field2];
char *field3 = (char *) sqlite3_column_text(statement, 2);
NSString *message = [[NSString alloc] initWithUTF8String:field3];
char *field4 = (char *) sqlite3_column_text(statement, 3);
NSString *recipient = [[NSString alloc] initWithUTF8String:field4];
char *field5 = (char *) sqlite3_column_text(statement, 4);
NSString *time = [[NSString alloc] initWithUTF8String:field5];
NSString *str = [[NSString alloc] initWithFormat:#"%#", message];
NSString *str1 = [[NSString alloc] initWithFormat:#"%#", channelID];
NSString *str2 = [[NSString alloc] initWithFormat:#"%#", sender];
NSString *str3 = [[NSString alloc] initWithFormat:#"%#", time];
NSString *trimmedStr2 = [str2 stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSString *trimmedAgentName = [box.agentName stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSString *trimmedTime = [str3 stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:#"yyyy-MM-dd HH:mm:ss ZZZ"];
NSDate *myDate = [df dateFromString:trimmedTime];
if ([trimmedStr2 isEqualToString:trimmedAgentName]) {
[self.messages addObject:[[JSMessage alloc] initWithText:str sender:trimmedAgentName date:myDate]];
[self finishSend];
[self scrollToBottomAnimated:YES];
} else {
[self.messages addObject:[[JSMessage alloc] initWithText:str sender:kSubtitleVisitor date:myDate]];
[self finishSend];
[self scrollToBottomAnimated:YES];
}
}
}
Edit
I've also tried to put the code inside a dispatch_queue, that made the switch to the view go a lot faster but the messages are still lagging behind when being added.
There are some places you can optimise in your code:
No need to create str str1 str2 str3, just use the message channelID sender time.
NSDateFormatter creation is expansive, you should create a instance outside the while loop.
viewDidLoad is called in UI thread, the query will take a long time to execute and block UI, you might want to execute SQL query in background. See Apple's Concurrency Programming Guide for more.
Related
//find all data from database
- (void) findAllSupplement
{
const char *dbpath = [_databasePath UTF8String];
sqlite3_stmt *statement;
if (sqlite3_open(dbpath, &_contactDB) == SQLITE_OK)
{
NSString *querySQL = [NSString stringWithFormat: #"SELECT * FROM SupplementInformationTable"];
const char *query_stmt = [querySQL UTF8String];
if (sqlite3_prepare_v2(_contactDB, query_stmt, -1, &statement, NULL) == SQLITE_OK)
{
NSMutableArray *allRows = [[NSMutableArray alloc] init] ;
while(sqlite3_step(statement) == SQLITE_ROW)
{
char *field1 = (char *) sqlite3_column_text(statement,0);
NSString *field1Str1 = [[NSString alloc] initWithUTF8String: field1];
char *field2 = (char *) sqlite3_column_text(statement,1);
NSString *field1Str2 = [[NSString alloc] initWithUTF8String: field2];
char *field3 = (char *) sqlite3_column_text(statement,2);
NSString *field1Str3 = [[NSString alloc] initWithUTF8String: field3];
char *field4 = (char *) sqlite3_column_text(statement,3);
NSString *field1Str4= [[NSString alloc] initWithUTF8String: field4];
char *field5 = (char *) sqlite3_column_text(statement,4);
NSString *field1Str5 = [[NSString alloc] initWithUTF8String: field5];
char *field6 = (char *) sqlite3_column_text(statement,5);
NSString *field1Str6 = [[NSString alloc] initWithUTF8String: field6];
char *field7 = (char *) sqlite3_column_text(statement,6);
NSString *field1Str7= [[NSString alloc] initWithUTF8String: field7];
char *field8 = (char *) sqlite3_column_text(statement,7);
NSString *field1Str8 = [[NSString alloc] initWithUTF8String: field8];
char *field9 = (char *) sqlite3_column_text(statement,8);
NSString *field1Str9 = [[NSString alloc] initWithUTF8String: field9];
NSMutableDictionary *dataDictionary=[[NSMutableDictionary alloc]init];
[dataDictionary setObject:field1Str1 forKey:#"supplementIdentity"];
[dataDictionary setObject:field1Str2 forKey:#"supplementName"];
[dataDictionary setObject:field1Str3 forKey:#"supplementDescription"];
[dataDictionary setObject:field1Str4 forKey:#"offerIdentity"];
[dataDictionary setObject:field1Str5 forKey:#"offerName"];
[dataDictionary setObject:field1Str6 forKey:#"offerDescription"];
[dataDictionary setObject:field1Str7 forKey:#"flavourIdentity"];
[dataDictionary setObject:field1Str8 forKey:#"imageLink"];
[dataDictionary setObject:field1Str9 forKey:#"quantityPurchase"];
// Add the string in the array.
[allRows addObject:dataDictionary];
NSLog(#"Match found") ;
//send all data to the cart container screen
CartContainer *objCartContainer=[[CartContainer alloc]init];
objCartContainer.arrayConatinLocalDataFromDB=allRows;
}
sqlite3_finalize(statement);
NSLog(#"%#",allRows);
}
sqlite3_close(_contactDB);
}
}
how i can call this function in app delegate ?this function is declared and define in view controller named productDetail.m .And i want to execute this function for my entire app. help will be appreciated.
Write the function in Appdelegate.m
And call from viewController.m
form this code:
AppDelegate *appDelegate;
appDelegate= (AppDelegate *)[UIApplication sharedApplication].delegate;
[appDelegate findAllSupplement];
Or you can declare the funtion globally. like:
In ViewController.h
+ (void) findAllSupplement;
And Define the funtion in ViewControler.m
+ (void) findAllSupplement
{
// your code here
}
And you can call the funtion from any class.
I am working with the SQLite i am able to create the table and alter table but after adding columns to the table, data is not fetching.
Up to now my implementation inserting table values like below
NSString *sqlString=[NSString stringWithFormat:#"insert into %#(toid,fromid,msg,timedate,left,messageID,chatStatus) values('%#','%#','%#','%#',%d,'%#','%#')",tableName,userid,friendid,message,timedate,(int)leftright,messageID,chatStatus];
below i am fetching data from table
-(NSMutableArray *)AllRowFromTableName:(NSString *)tableName withUserID:(NSString *)userid withFriendID:(NSString *)friendid
{
NSMutableArray *array=[[NSMutableArray alloc] init];
NSString *sqlString=[NSString stringWithFormat:#"select *from chatTable where toid='%#' and fromid='%#'",userid,friendid];
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(db, [sqlString UTF8String], -1, &statement, nil)==SQLITE_OK) {
while (sqlite3_step(statement)==SQLITE_ROW) {
ChatHistorySkeleton *tempSkeleton=[[ChatHistorySkeleton alloc] init];
tempSkeleton.u_id =[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(statement, 1)];//f_id
// NSString *strn = [NSString stringWithFormat:#"%#",tempSkeleton.mToID];
tempSkeleton.f_id=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(statement, 2)];
tempSkeleton.msg=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(statement, 3)];
//tempSkeleton.fromMe=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(statement, 3)];
// tempSkeleton.fromMe=((int)sqlite3_column_int(statement, 4)) ? YES : NO;
tempSkeleton.lft_rght=(int)sqlite3_column_int(statement, 4);
tempSkeleton.tim_dte=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(statement, 5)];
//if messageID Null
char *messageIDForEmptyCheck = (char *)sqlite3_column_text(statement, 6);
NSString *messageID1 = messageIDForEmptyCheck?[[NSString alloc]initWithUTF8String:messageIDForEmptyCheck]:#"";
tempSkeleton.messageID=messageID1;
//if chat status Null
char *chatStatus = (char *) sqlite3_column_text(statement,7);
NSString *chatStatus1 = chatStatus?[[NSString alloc]initWithUTF8String:chatStatus]:#"";
tempSkeleton.chatStatus=chatStatus1;
[array addObject:tempSkeleton];
// NSLog(#"IN LOOP=>%#",array);
}
}
return array;
}
I just alter table and added two columns messageID,chatstatus but these two values showing empty. What I am missing?
I am developing a chatting app in that i am using sqlite for storing and retrieving chat history i am able to insert the values but while retrieving i am getting the nil in array here is my code
messageArray=[DBObject AllRowFromTableName:#"chatTable" withUserID:myJID withFriendID:chatWithUser];
for (int i=0; i<[messageArray count]; i++) {
Message *msg=[[Message alloc] init];
msg.text=[[messageArray objectAtIndex:i] msg];
if ([[messageArray objectAtIndex:i] lft_rght]==0) {
msg.fromMe=YES;
}
else{
msg.fromMe=NO;
}
msg.type=SOMessageTypeText;
NSString *dateString =[[messageArray objectAtIndex:i] tim_dte];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:#"HH:mm,yyyy/MM/dd"];
NSDate *dateFromString = [[NSDate alloc] init];
dateFromString = [dateFormatter dateFromString:dateString];
msg.date=dateFromString;
[self.chatHistoryArray addObject:msg];
this is my retrieving class ad database class is
-(NSMutableArray *)AllRowFromTableName:(NSString *)tableName withUserID:(NSString *)userid withFriendID:(NSString *)friendid
{
NSMutableArray *array=[[NSMutableArray alloc] init];
NSString *sqlString=[NSString stringWithFormat:#"select *from chatTable where toid='%#' and fromid='%#'",userid,friendid];
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(db, [sqlString UTF8String], -1, &statement, nil)==SQLITE_OK) {
while (sqlite3_step(statement)==SQLITE_ROW) {
Message *tempSkeleton=[[Message alloc] init];
tempSkeleton.mToID =[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(statement, 1)];
tempSkeleton.mFromID=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(statement, 2)];
tempSkeleton.text=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(statement, 3)];
//tempSkeleton.fromMe=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(statement, 3)];
tempSkeleton.fromMe=((int)sqlite3_column_int(statement, 4)) ? YES : NO;
tempSkeleton.tim_dte=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(statement, 5)];
[array addObject:tempSkeleton];
// NSLog(#"IN LOOP=>%#",array);
}
}
i am getting msg.text empty can ay body help me please
IN your loop that is processing the returned array, these lines...
Message *msg=[[Message alloc] init];
msg.text=[[messageArray objectAtIndex:i] msg];
It should just be...
Message *msg=[[Message alloc] init];
msg.text=[[messageArray objectAtIndex:i] text];
You should also create the NSDateFormatter once, outside of the loop, and use that, as its not a "quick" object to create.
You might also want to refactor the constant calls to [messageArray objectAtIndex:i]. Create a local variable that gets hold of the reference once and then use that. So refactored code would look something like...
messageArray=[DBObject AllRowFromTableName:#"chatTable" withUserID:myJID withFriendID:chatWithUser];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:#"HH:mm,yyyy/MM/dd"];
for (int i=0; i<[messageArray count]; i++) {
Message * baseMessage = [messageArray objectAtIndex:i];
Message *msg=[[Message alloc] init];
msg.text= baseMessage.text;
msg.fromMe= (baseMessage.left_rght == 0);
msg.type=SOMessageTypeText;
msg.date=[dateFormatter dateFromString:baseMessage.tim_dte];
[self.chatHistoryArray addObject:msg];
}
You could also use fast enumerators and maybe check out modern objective c https://developer.apple.com/library/ios/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObjective-C/AdoptingModernObjective-C.html
i am Newbie in iOS Development, and First time Use Sqllite database so Sorry For this Question but i am So Confusing Please Give me Solution for this.
I added Data in to My Sqllite Table Like as
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
sqlite3_stmt *statement;
const char *dbpath = [_databasePath UTF8String];
if (sqlite3_open(dbpath, &_myDatabase) == SQLITE_OK) {
NSString *insertSQL = [NSString stringWithFormat:
#"INSERT INTO ALLREADTABLE (PostId, PostTitle, ImageLink, ShortDescription,Category,PostDate) VALUES (\"%#\", \"%#\", \"%#\", \"%#\",\"%#\",\"%#\")",
post_id, cell.headLabel.text, image,self.shortDiscription,cell.categoryLabel.text,cell.timeLabel.text];
const char *insert_stmt = [insertSQL UTF8String];
sqlite3_prepare_v2(_myDatabase, insert_stmt,
-1, &statement, NULL);
if (sqlite3_step(statement) == SQLITE_DONE)
{
NSString *string=[NSString stringWithFormat:#"Value Added %# %# %# %# %# %#",post_id, cell.headLabel.text, image,self.shortDiscription,cell.categoryLabel.text,cell.timeLabel.text];
NSLog(#"String %#",string);
} else
{
NSLog(#"Failed to add contact");
}
sqlite3_finalize(statement);
sqlite3_close(_myDatabase);
}
Then it is added data in to Data Base as I want and it also added Duplicate Value in to table , so For Distinct Value i Write a Code to Fetch data like as
- (void)getTextFomDB
{
NSString *docsDir;
NSArray *dirPaths;
// Get the documents directory
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];
// Build the path to the database file
_databasePath = [[NSString alloc]
initWithString: [docsDir stringByAppendingPathComponent:
#"sampleDatabase.db"]];
const char *dbpath = [_databasePath UTF8String];
sqlite3_stmt *statement;
if (sqlite3_open(dbpath, &_myDatabase) == SQLITE_OK)
{
NSString *querySQL = #"SELECT DISTINCT PostId, PostTitle, ImageLink, ShortDescription,Category,PostDate FROM ALLREADTABLE";
const char *query_stmt = [querySQL UTF8String];
if (sqlite3_prepare_v2(_myDatabase, query_stmt, -1, &statement, NULL) == SQLITE_OK)
{
[self.postId removeAllObjects];
[self.postTitle removeAllObjects];
[self.imageLink removeAllObjects];
[self.shortDecsription removeAllObjects];
[self.category removeAllObjects];
[self.postDate removeAllObjects];
while (sqlite3_step(statement) == SQLITE_ROW) {
//NSString *personID = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 0)];
NSString *postId = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 1)];
NSString *postTitle = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 2)];
NSString *ImageLink = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 3)];
NSString *shortDescrip = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 4)];
NSString *Category = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 5)];
NSString *postDate = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 6)];
[self.postId addObject:[NSString stringWithFormat:#"%# ", postId]];
[self.postTitle addObject:[NSString stringWithFormat:#"%# ",postTitle]];
[self.imageLink addObject:[NSString stringWithFormat:#"%#",ImageLink]];
[self.shortDecsription addObject:[NSString stringWithFormat:#" %#",shortDescrip]];
[self.category addObject:[NSString stringWithFormat:#" %#",Category]];
[self.postDate addObject:[NSString stringWithFormat:#" %#",postDate]];
}
sqlite3_finalize(statement);
}
sqlite3_close(_myDatabase);
}
}
Then it Give me Error like as
[NSPlaceholderString initWithUTF8String:]: NULL cString
Here I want Distinct Value From My SqlliteTable. please Give me Solution For that. I know It is easy But i am Newbie in Database so please Sorry
and Thanks in advance.
You are using initWithUTF8String to get values from database, So if there is a field in database which accept null data than it will gives you an error when you are trying to fetch null data from database.
I suggest you replace all data retrieving code like
NSString *postId = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 1)];
with below code:
NSString *postId = [NSString stringWithUTF8String:(const char *) sqlite3_column_text(statement, 1)];
This will replace not null data to an empty string.
This is being caused by trying to create a NSString object with a NULL string. It is on one of these lines:
[[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, ...)];
So, before you create a NSString with the results of the sql statement you need to check for NULL like this:
char *tmp = sqlite3_column_text(statement, 1);
if (tmp == NULL)
postId = nil;
else
postId = [[NSString alloc] initWithUTF8String:tmp];
Reference: lnafziger
Im working on a iOS app, so i need to save a image that the user will choose from his album or will take it from the camera. Im doing this with a picker
Then i try to save the image into the table with this code:
- (IBAction)saveUOme:(id)sender
{
NSString * _name = name.text;
NSString * _lastname = lastname.text;
NSString * _email = email.text;
NSString * _workemail = workEmail.text;
NSString * _cellphone = cell.text;
NSString * _phone = homePhone.text;
NSString * _money = amount.text;
NSString * _stuff = stuff.text;
NSString * _cause = cause.text;
//NSData *_image = UIImagePNGRepresentation(image);
NSData *_image = [NSData dataWithData:UIImagePNGRepresentation(image)];
NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init];
[dateformatter setDateFormat:#"yyyy-MM-dd"];
NSString * _date = [dateformatter stringFromDate:[datePicker date]];
if (!switchR.on)
{
_date=#"";
}
//NSString *_error;
NSLog(#" %# ,%# ,%# ,%# ,%# ,%#,%#,%#,%#,%# ", _name,_lastname,_email,_workemail,_cellphone,_phone,_money,_stuff,_cause,_date);
if(([_name length]!=0 && [_lastname length] !=0 && [_money length] !=0) || ([_name length]!=0 && [_lastname length] !=0 && [_stuff length] !=0 ) )
{
NSString *query = [NSString stringWithFormat:#"INSERT INTO addUOmeTable ('name','lastname','email','workemail','cellphone','phone','money','stuff','cause','date','image') VALUES ('%#','%#','%#','%#','%#','%#','%#','%#','%#','%#','%#');", _name, _lastname, _email, _workemail, _cellphone, _phone,_money,_stuff,_cause,_date,_image];
char *err;
if (sqlite3_exec(_db, [query UTF8String], NULL, NULL, &err) != SQLITE_OK)
{
sqlite3_close(_db);
NSAssert(0,#"No se pudo agregar");
}else
{
NSLog(#"Se agregaron los datos");
}
}else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Some Data is Missing"
message:#"Name, Lastname or Amount/Stuff"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
/*
FirstViewController *obj =[[FirstViewController alloc]initWithNibName:#"FirstViewController" bundle:nil];
[self.view addSubview:obj.view];*/
//[self.navigationController pushViewController:obj animated:YES];
}
}
So far i think this works because in the database i get this as save object
<89504e47 0d0a1a0a 0000000d 49484452 00000400 00000300 08020000 0035d882 5a000000 1c69444f 54000000 02000000 00000001 80000000 28000001 80000001 80000c6c fd9ea091 34000040 00494441 5478019c 7df7775c 45b6357f ce7b3360 a5ce4959 b2255956 ce9d734e ea56ce96 73c0186c c0806d8c 73ced9c6 e4641be7 086f6698 21e300cc fbf9dbb7 4feb50be 2d9b79df 5a67d5da 75ead4a9 bab7c33d fb567a2e 38520e09 0f574222 4395e1c1 8ae84065 46aac37d 95c1de4a 7fa2dc93 2873c74b 9db1325b acbc275c da1d2eef 8c967644 4ada22a6 d6b0be29 ac6b8ea8 5b23eaf6 88aa3ba6 b624d4ce 84d693d2 85fb0df1 2153efa0 2135a84b 0de953a.....>
Then i try to select all from the database with this code
-(void) selectData
{
NSString *query = [NSString stringWithFormat:#"SELECT * FROM addUOmeTable ORDER BY name ASC"];
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(_db, [query UTF8String], -1, &statement, Nil)== SQLITE_OK)
{
while (sqlite3_step(statement)==SQLITE_ROW)
{
char *id1 = (char *) sqlite3_column_text(statement, 0);
NSString *id_uomeDoubt = [[NSString alloc] initWithUTF8String:id1];
char *name1 = (char *) sqlite3_column_text(statement, 1);
NSString *name = [[NSString alloc] initWithUTF8String:name1];
char *lastname1 = (char *) sqlite3_column_text(statement, 2);
NSString *lastname = [[NSString alloc] initWithUTF8String:lastname1];
char *email1 = (char *) sqlite3_column_text(statement, 3);
NSString *email = [[NSString alloc] initWithUTF8String:email1];
char *workemail1 = (char *) sqlite3_column_text(statement, 4);
NSString *workemail = [[NSString alloc] initWithUTF8String:workemail1];
char *cellphone1 = (char *) sqlite3_column_text(statement, 5);
NSString *cellphone = [[NSString alloc] initWithUTF8String:cellphone1];
char *phone1 = (char *) sqlite3_column_text(statement, 6);
NSString *phone = [[NSString alloc] initWithUTF8String:phone1];
char *money1 = (char *) sqlite3_column_text(statement, 7);
NSString *money = [[NSString alloc] initWithUTF8String:money1];
char *staff1 = (char *) sqlite3_column_text(statement, 8);
NSString *staff = [[NSString alloc] initWithUTF8String:staff1];
char *couse1 = (char *) sqlite3_column_text(statement, 9);
NSString *couse = [[NSString alloc] initWithUTF8String:couse1];
char *date1 = (char *) sqlite3_column_text(statement, 10);
NSString *date = [[NSString alloc] initWithUTF8String:date1];
NSData *data = [[NSData alloc] initWithBytes:sqlite3_column_blob(statement, 11) length:sqlite3_column_bytes(statement, 11)];
doubtArr = [NSArray arrayWithObjects:id_uomeDoubt,name,lastname,email,workemail,cellphone,phone,money,staff,couse,date,data, nil];
[uomeDoubts addObject:doubtArr];
}
}
[self.myTable reloadData];
}
And finally i try to display the image into a cell using this code
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier=#"Cell";
CustomeCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if(!cell)
{
cell= [[CustomeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"Cell"];
}
NSArray *debtor = [uomeDoubts objectAtIndex:indexPath.row];
NSString *nombre = [debtor objectAtIndex:1];
NSString *nombre2 = [debtor objectAtIndex:1];
NSString *apellido = [debtor objectAtIndex:2];
nombre = [nombre stringByAppendingString:#" "];
nombre = [nombre stringByAppendingString:[debtor objectAtIndex:2]];
cell.TitleLable.text = nombre;
NSString *tempo = [debtor objectAtIndex:7] ;
if ([tempo length] ==0)
{
NSString *st = #"Stuff - ";
st = [st stringByAppendingString:[debtor objectAtIndex:8]];
cell.SubtitleLable.text = st;
}
else
{
NSString *mny = #"Money - $";
mny = [mny stringByAppendingString:[debtor objectAtIndex:7]];
cell.SubtitleLable.text = mny;
}
NSLog(#"%# %#",nombre2,apellido);
NSData* data = [debtor objectAtIndex:11];
cell.imageView.image = [UIImage imageWithData:data];
return cell;
}
And i dont get any error , the only thing is that the image is not display at all
PLEASE HELP!