Add Via For Loop with Dictionary

for (int i = 0; i<self.dataArray.count; i++)
{
NSDictionary *innerDic = self.dataArray[i];

NSString *strQuery = [NSString stringWithFormat:@”INSERT INTO main.tblFav (\”memId\”,\”firstname\”,\”fathername\”,\”lastname\”,\”address1\”,\”address2\”,\”area\”,\”city\”,\”native\”,\”phMobile\”,\”phHome\”,\”phOffice\”,\”gender\”,\”dob\”,\”height\”,\”education\”,\”occupation\”,\”srNo\”,\”Cat\”,\”Subcat\”) VALUES (\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”,\”%@\”)”,[innerDic objectForKey:@”Id”],[innerDic objectForKey:@”FirstName”],[innerDic objectForKey:@”MiddleName”],[innerDic objectForKey:@”LastName”],@””,@””,@””,[innerDic objectForKey:@”City”],[innerDic objectForKey:@”Native”],[innerDic objectForKey:@”PhnMobile”],[innerDic objectForKey:@”PhnHome”],[innerDic objectForKey:@”PhnWork”],@””,@””,@””,@””,@””,@””,@”1″,subCat];

[database executeUpdate:strQuery];

}

===================****************====================

NSString *insertSQL = [NSString stringWithFormat:
@”INSERT INTO tblCartList (ProductID,ProductTitle,ProductDate,ProductTime,ProductImage,TotalCoast,Quantity,CartBadgeCount,ProductDetails,ProductPrice) VALUES (\”%@\”, \”%@\”, \”%@\”, \”%@\”, \”%@\”, \”%f\”, \”%@\”, \”%d\”, \”%@\”, \”%@\”)”,strProductID,
lblProductTitle.text,txtDeliveryDt.text,txtDeliveryTime.text, strImagURL , total,
lblQuantity.text,cartbadge,strProductDetails,strProductPrice];

BOOL success=[database executeUpdate:insertSQL];

 

====================******************====================

for (NSDictionary *dictn in taskDetailsArray)
{
if ([[dictn objectForKey:@”TaskTypeName”]isEqualToString:@”Procedure”]){

[ActivityArry addObject:dictn];
}
}

====================******************======================

//Short array and display list as a date Wise…..
for (int i = 0; i<reverseOrder.count; i++) {
//Set date as per Order…..
tmpString = [[reverseOrder objectAtIndex:i] objectForKey:@”ActivityDate”];
if (![arrKeys containsObject:tmpString])
{
[arrKeys addObject:tmpString];
}
}
for (int i=0 ;i<[arrKeys count]; i++)
{
NSMutableArray *arr=[[NSMutableArray alloc]init];
for (int j=0; j<[reverseOrder count]; j++)
{
NSMutableDictionary *dict=[[NSMutableDictionary alloc]initWithDictionary:[arrayData objectAtIndex:j]];
NSString *strDate = [dict objectForKey:@”ActivityDate”];

if ([[arrKeys objectAtIndex:i] isEqual:strDate])
{
[arr addObject:dict];
}
}
[historyDataArray addObject:arr];
}

 

============================================================

– (void)addDataDB{
database=[FMDatabase databaseWithPath:self.path];

if(![database open])
NSLog(@”%@”,[database lastErrorMessage]);

NSString *strQuery;

for (int i = 0; i < recordArr.count; i++) {

[database open];
NSDictionary *dict = [recordArr objectAtIndex:i];

if ([dict objectForKey:@”name”] == nil && [dict objectForKey:@”sub_cat_id”])
{
NSLog(@”Name not found”);
return;
}
else if ([dict objectForKey:@”sub_cat_id”] == nil)
{
NSLog(@”sub_cat_id not found”);
return;
}

NSString *name = [dict valueForKey:@”name”];
NSString *sub_cat_id = [NSString stringWithFormat:@”%@”,[dict valueForKey:@”sub_cat_id”]];

strQuery = [NSString stringWithFormat:@”INSERT INTO tblEmp (\”Name\”,\”Age\”) VALUES (\”%@\”,\”%@\”)”,name,sub_cat_id];

BOOL success=[database executeUpdate:strQuery];

if(success){
self.msg=@”record insertd successfully”;
NSLog(@”record insertd successfully”);
}
else{
self.msg=[database lastErrorMessage];
}

[database close];
}
}

=========

– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

NSString * identifier=[NSString stringWithFormat:@”MenuCell”];
MenuCell *cell=(MenuCell *)[tableView dequeueReusableCellWithIdentifier:identifier];
if(cell == nil){
cell=[[MenuCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier ];
}
NSLog(@”recordArr===> %@”,recordArr);

NSDictionary *dict = [recordArr objectAtIndex:indexPath.row];

cell.lblTitle.text = [dict valueForKey:@”name”];
return cell;

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s