Ios 从NSNumber检索内容时出现问题

Ios 从NSNumber检索内容时出现问题,ios,nsnumber,Ios,Nsnumber,听起来像个愚蠢的问题。我试图从定义为NSNumber的变量中检索内容,该变量是从可变数组读取的: NSNumber * nsnMoneyPerMonth; nsnMoneyPerMonth=[[[myTableData objectAtIndex:0] objectAtIndex:myIndexPath.row]objectForKey:@"moneyPerMonth"]; int moneyPerMonth=sqlite3_column_int(statement, 1); NSNumb

听起来像个愚蠢的问题。我试图从定义为NSNumber的变量中检索内容,该变量是从可变数组读取的:

NSNumber * nsnMoneyPerMonth;
nsnMoneyPerMonth=[[[myTableData objectAtIndex:0]  objectAtIndex:myIndexPath.row]objectForKey:@"moneyPerMonth"];

int moneyPerMonth=sqlite3_column_int(statement, 1); 
NSNumber *nsnumberMoneyPerMonth=[NSNumber numberWithInt:moneyPerMonth]; 
[NSMutableDictionary alloc]initWithObjectsAndKeys:nsnumberMoneyPerMonth,@"moneyPerMonth"
现在,一切都好了。但是,当我添加一行代码时,如:

int intMoneyPerMonth=[nsnMoneyPerMonth intValue];
要尝试检索内容,将抛出EXC\u BAD\u访问


那么,我做错了什么?

你确定你的NSNumber是整数而不是浮点值吗?@verhage:是的,我想是的,下面是一些你可能感兴趣的代码:int-moneyPerMonth=sqlite3\u column\u int(语句,1);NSNumber*nsnumberMoneyPerMonth=[NSNumber numberwhithint:moneyPerMonth];[NSMutableDictionary alloc]initWithObjects和Keys:nsnumberMoneyPerMonth,@“moneyPerMonth”,我在原始问题中添加了您的代码,因为它很难阅读,但我仍然不明白您想做什么。你能检查并完善上面的代码吗?从您得到的错误中,我怀疑您正在访问一个无效(nil)指针;喂?@Jacob我试过了,但也被抛出了EXC_BAD_ACCESS。。