如何在保存值动态创建Textfield时迭代plist

时间:2012-03-26 10:06:03

标签: iphone ios

如何迭代plist并保存数据并使用标记检索动态创建的文本字段上的数据... 请给出一些可能的解决方案......

这个3 nsmutableArray有三个diff动态文本字段。先生,这不是我的问题的一部分..我有问题保存在plist ..当我保存plist文本字段方法再次调用线条

[Txt_New_Estimated addTarget:self action:@selector(Calculate12)forControlEvents:UIControlEventEditingChanged]; // UIControlEventEditingDidEnd,

这就是每次当我给出像456这样的值时循环运行的原因,lopp将运行3次并且它将值存储在plist上的3个不同的索引,如索引0 - > 4,索引1 - > 45,指数三 - > 456

-(void)addfg{
// I want to iterate this line

// When i give some value on my dynamic textfield this loop run and save the value.
// Suppose i give "3" the value save successfully . on index xero->3
// but when i give 456 the loop will run three times and save the value on three different indexs
// such as index zero->4 , index 1-<45 , index 3->456 
// how to solve this?


[form1Array9 addObject: Txt_New_ONU.text];  // 0
int A=[form1Array9 count];
NSLog(@"A is %d",A);


NSLog(@"Diff is %f",diff);



[self arrayStore:form1Array9];


savedAlert = [[UIAlertView alloc]initWithTitle:@"" message:@"Data saved successfully"  delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[savedAlert show];
[savedAlert release];


}


-(void)Calculate12{
f = 0;
for(UITextField *fields in textFieldArray1) // will iterate all UITextField which was added
{
f += [fields.text intValue]; //or floatValue
for ( p = 0; p < textFieldArray1.count; p++) {

UITextField *textField1 = [textFieldArray objectAtIndex:p];
NSLog(@"txt1 is %d",p);

UITextField *textField2 = [textFieldArray1 objectAtIndex:p];
NSLog(@"txt2 is %d",p);



 diff = [textField2.text floatValue] - [textField1.text floatValue];

Txt_New_ONU = [textFieldArray2 objectAtIndex:p];     NSLog(@“txt3是%d”,p);

Txt_New_ONU.tag = p;
NSLog(@" i  is %d", p);  


Txt_New_ONU.text = [[NSString alloc] initWithFormat:@"%.2f",diff];
NSLog(@"Diff is %f",diff); 

}


f1= ([Txt_Engring_Act.text floatValue]) + ([Txt_Weddring_Act.text floatValue]) +     ([Txt_Bridal_Act.text floatValue])+ ([Txt_Veil_Act.text floatValue])+f;

Txt_Total_Act.text = [[NSString alloc] initWithFormat:@"%.2f",f1];

}




[self addfg];

}

0 个答案:

没有答案