通过NSArray迭代

时间:2010-07-06 00:49:47

标签: objective-c nsarray fast-enumeration

有人可以帮我修复我的代码吗?我试图做一些简单的迭代遍历整个数组,其中包含NSString,将它们转换为NSIntegers并将它们分配给NSInteger变量。

 for  (NSInteger *itemF in myNSArray) {
     //WHERE "slotA" is an NSInteger and "itemF" is stored as an NSString and I wanna conver to NSInteger 
     //and store is in the var.
     slotA=itemF;          
}  

1 个答案:

答案 0 :(得分:7)

for (NSString *string in array)
{
  NSInteger integer = [string integerValue]; 
}