Reputation: 589
I am working with Sqlite Database.
In my database
I have some filed Like, Invoice,Name,Date
My Invoiceno datatype is INTEGER,
In Select query Got output like this.
Query:(
{
InvoiceNo = 1;
Name : ABC
Date = "2012-04-16 00:00:00";
}
)
But when try to Get that Invoice no to string it's given Diff. Value.
Code for getting invoice from array to String:
NSString *str = [NSString stringWithFormat:@"%i",[[Query objectAtIndex:indexPath.row] valueForKey:@"InvoiceNo"]];
NSLog(@"str:%@",str);
Here, My invoice no is 1, & It's give me a value "2387056"
Please, Help me..How can i solve this problem?
Upvotes: 1
Views: 2164
Reputation: 11338
NSString *values = @"1";
int yourValue = [values intValue];
NSLog(@"Int Value : %d",yourValue);
Upvotes: 1
Reputation: 6323
NSString *str = [NSString stringWithFormat:@"%i",[[Query objectAtIndex:indexPath.row] valueForKey:@"InvoiceNo"]];
NSLog(@"str:%@",str);
you have to replace above lines with below lines
NSString *str = [NSString stringWithFormat:@"%i",[[[Query objectAtIndex:indexPath.row] valueForKey:@"InvoiceNo"] intValue]];
NSLog(@"str:%@",str);
Upvotes: 2