无法从我的 for 循环中向 NSmutableArray 添加超过 260 个元素的元素
Unable to add elements in NSmutableArray more than 260 elements from my for loop
这是代码。我们无法获得完整的数组元素。它限制为 260 个元素,但有 360 个元素。
-(void)scheduleCal{
float monthlyPayment = 0.0; //monthly Payment
float loanAmount = 100000; //Loan Amount
int years = 30;
float intRate = 6;
float i = intRate / 1200;
int n = years * 12;// 360
float rPower = pow(1+i, n);
float mPayment = loanAmount*((i*(pow((1+i), n)))/((pow(1+i, n))-1));
monthlyPayment = loanAmount * i * rPower / (rPower -1);
NSLog(@"Monthly Payment:%0.2f %f",mPayment,round(monthlyPayment));
float tempLoanAmount = loanAmount;
self.array = [[NSMutableArray alloc] init];
for (int r = 1; r <= n; r++) {
float interestPayment = tempLoanAmount *i;
double principalPayment = mPayment - interestPayment;
tempLoanAmount -= principalPayment;
NSDictionary *dic = @{@"sno":[NSString stringWithFormat:@"%d",r],@"principal": [NSString stringWithFormat:@"%0.2f",principalPayment],@"interest":[NSString stringWithFormat:@"%0.2f",interestPayment],@"balance":[NSString stringWithFormat:@"%0.2f",tempLoanAmount]};
[self.array addObject:dic];
dic = nil;
}
NSLog(@"Array:%@ %ld",self.array,(unsigned long)self.array.count);
}
代码没有错。代码非常好。数组包含 360 个元素。它刚刚被剪辑在控制台上。如果您需要在控制台上查看或打印全部内容,请使用以下任何一种方式。
for (NSDictionary *dict in self.array) {
NSLog(@"Dict: %@ ",dict);
}
OR
printf("%s", [NSString stringWithFormat: @"%@", array].UTF8String);
这是代码。我们无法获得完整的数组元素。它限制为 260 个元素,但有 360 个元素。
-(void)scheduleCal{
float monthlyPayment = 0.0; //monthly Payment
float loanAmount = 100000; //Loan Amount
int years = 30;
float intRate = 6;
float i = intRate / 1200;
int n = years * 12;// 360
float rPower = pow(1+i, n);
float mPayment = loanAmount*((i*(pow((1+i), n)))/((pow(1+i, n))-1));
monthlyPayment = loanAmount * i * rPower / (rPower -1);
NSLog(@"Monthly Payment:%0.2f %f",mPayment,round(monthlyPayment));
float tempLoanAmount = loanAmount;
self.array = [[NSMutableArray alloc] init];
for (int r = 1; r <= n; r++) {
float interestPayment = tempLoanAmount *i;
double principalPayment = mPayment - interestPayment;
tempLoanAmount -= principalPayment;
NSDictionary *dic = @{@"sno":[NSString stringWithFormat:@"%d",r],@"principal": [NSString stringWithFormat:@"%0.2f",principalPayment],@"interest":[NSString stringWithFormat:@"%0.2f",interestPayment],@"balance":[NSString stringWithFormat:@"%0.2f",tempLoanAmount]};
[self.array addObject:dic];
dic = nil;
}
NSLog(@"Array:%@ %ld",self.array,(unsigned long)self.array.count);
}
代码没有错。代码非常好。数组包含 360 个元素。它刚刚被剪辑在控制台上。如果您需要在控制台上查看或打印全部内容,请使用以下任何一种方式。
for (NSDictionary *dict in self.array) {
NSLog(@"Dict: %@ ",dict);
}
OR
printf("%s", [NSString stringWithFormat: @"%@", array].UTF8String);