标签: nsarray

由于未捕获的异常“NSRangeException”而终止应用程序,原因:“*** -[__NSArray0 objectAtIndex:]:索引 2 超出空 NSArray 的范围

日志中的错误:

* 由于未捕获的异常“NSRangeException”而终止应用程序,原因:“* -[ NSArray0 objectAtIndex:]:索引 2 超出空 NSArray 的范围”*** 第一个抛出调用堆栈:( 0 CoreFoundation 0x000000010fdd8b0b __exceptionPreprocess + 171 1 libobjc.A. dylib 0x00000001143a6141 objc_exception_throw + 48 2 CoreFoundation 0x000000010fdf027d -[__NSArray0 objectAtIndex:] + 93 3 DropInn 0x000000010d598fc4 _TFC7DropInn21ListingViewController9tableViewfTCSo11UITableView 14didSelectRowAtV10Foundation9IndexPath_T_ + 5972 4 DropInn 0x000000010d599837 _TToFC7DropInn21ListingViewController9tableViewfTCSo11UITableView14didSelectRowAtV10Foundation9IndexPath_T_ + 87 5 UIKit 0x00000001122b3dcd -[UI TableView _selectRowAtIndexPath:动画:scrollPosition:notifyDelegate:] + 1763 6 UIKit 0x00000001122b3fe3 -[ UITableView _userSelectRowAtPendingSelectionIndexPath:] + 344 7 UIKit 0x00000001121697f3 _runAfterCACommitDeferredBlocks + 318 8 UIKit 0x00000001121567bc _cleanUpAfterCAFlushAndRunDeferredBlocks + 532 9 UIKit 0x000000011218828c _afterCACommitHandler + 137 10 CoreFoundation …

nsarray ios nsrangeexception swift

1
推荐指数
1
解决办法
8397
查看次数

NSArray FilteredArrayUsingPredicate 内存泄漏

尝试NSPredicate在 for 循环中使用在日期范围内NSArray具有NSDate字段值的记录时,我遇到了巨大的内存泄漏- 像这样:

for(int i=0;i<nLen;i++)
{
  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date >=  %@ AND date <=  %@", dateStart,dateEnd];
  NSArray *result = [myDataArray filteredArrayUsingPredicate:predicate];
} 
Run Code Online (Sandbox Code Playgroud)

简单的测试表明它filteredArrayUsingPredicate是泄漏的函数。

在 iPhone 7s 上使用 XCode 版本 9.2 (9C40b) 和 iOS 11.2.1。

有没有其他人看到这个?

memory-leaks core-data objective-c nsarray

1
推荐指数
1
解决办法
199
查看次数

我可以将同一个对象添加到两个不同的数组中吗?

这是有效的:

 NSObject anObject = [[NSObject alloc] init];
 [array1 addObject:anObject];
 [array2 addObject:anObject];
Run Code Online (Sandbox Code Playgroud)

我的钱是肯定的,因为我只是添加对同一个对象的引用,或者我错了吗?

cocoa object objective-c foundation nsarray

0
推荐指数
1
解决办法
381
查看次数

为什么NSArray确实有indexOfObject方法而NSMutableArray没有?

我想从a中删除一个特定元素NSMutableArray,我看到NSArray有indexOfObject一个对此非常有用的方法,但NSMutableArray没有.

我目前的方法是使用removeObjectsInArray方法NSMutableArray作为参数传递包含我的object/s的数组.

有没有更好的方法呢?有什么理由NSMutableArray没有这种方法吗?

iphone objective-c nsmutablearray nsarray

0
推荐指数
1
解决办法
609
查看次数

iPhone:超越界限[0 .. 8]'

这真让我抓狂!我一直在崩溃这个错误.以下是我的代码.我试图在我的UITabelView中添加一个额外的单元格以获得"25个以上"的功能.但是我在heightForRowAtIndexPath函数内部崩溃了.我在俯瞰什么?

TIA.

[NSMutableArray objectAtIndex:]:索引4294967295超出边界[0 .. 8]'

0 CoreFoundation
0x01338be9 __exceptionPreprocess + 185 1 libobjc.A.dylib
0x0148d5c2 objc_exception_throw + 47 2 CoreFoundation
0x0132e6e5 - [__ NSArrayM objectAtIndex:] + 261 3
mackdabMobile
0x00004f56 - [AllmackTableViewController tableView:heightForRowAtIndexPath:] +

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
    {
        NSLog(@"IndexRow int: %i", indexPath.row);
        NSLog(@"postsArray count: %i", [postsArray count]);
        if(indexPath.row < [postsArray count]){  **<----Where it crashes**
            Post *myPost = [postsArray objectAtIndex:[indexPath row] - 1];
            NSString *text = myPost.description;

            CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 88.0f);

            CGSize size = …
Run Code Online (Sandbox Code Playgroud)

iphone nsarray ios

0
推荐指数
1
解决办法
1210
查看次数

在数组对象中查找数组对象的索引

举个例子,如果我有这个数组:

_mode = [NSArray arrayWithObjects:
                      [NSArray arrayWithObjects:@"1", @"One", nil],
                      [NSArray arrayWithObjects:@"2", @"Two", nil],
                      [NSArray arrayWithObjects:@"3", @"Three", nil],
                      [NSArray arrayWithObjects:@"4", @"Four", nil],
                      [NSArray arrayWithObjects:@"5", @"Five", nil],
                      nil];
Run Code Online (Sandbox Code Playgroud)

我需要找到数组_mode的哪个对象包含@"3"我该怎么做?我尝试过selectedIndex = [_mode indexOfObject:@"3"];,selectedIndex = [[_mode objectAtIndex:0] indexOfObject:@"sta"];但都没有工作.

xcode cocoa-touch objective-c nsarray

0
推荐指数
1
解决办法
2638
查看次数

将单个数组分成两个数组的代码如何?

当我使用来自我所需URL的JSON解析时,我对nsarray的响应低于此,但在这里我不想得到2,1,4,4,6,5,8,7,10,9,12和11在单个数组中,我必须得到两个数组的总响应,我的意思是一个数组将包含2,4,6,8,10,其他数组必须是3,5,7,9和11.

那么在iPhone中将单个阵列响应分离为两个数组的代码如何?

"(\n    2,\n    1\n)",
"(\n    4,\n    3\n)",
"(\n    6,\n    5\n)",
"(\n    8,\n    7\n)",
"(\n    10,\n    9\n)",
"(\n    12,\n    11\n)"
Run Code Online (Sandbox Code Playgroud)

iphone nsarray ios

0
推荐指数
1
解决办法
269
查看次数

根据数据对数组进行排序

我有一个tableview,显示存储在NSObject中的数组中的数据.NSObject中的一个属性是inputtime(currentCall.inputtime),我想根据它对我显示的数据进行排序.我该怎么做呢?谢谢.

这是我的cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    JointCAD *currentCall = [[xmlParser calls] objectAtIndex:indexPath.row];
    static NSString *cellidentifier1 = @"cell1";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellidentifier1];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellidentifier1];
    }

    cell.textLabel.text = currentCall.currentCallType;
    cell.detailTextLabel.text = currentCall.location;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;
}
Run Code Online (Sandbox Code Playgroud)

sorting objective-c nsarray xml-parsing ios

0
推荐指数
1
解决办法
5246
查看次数

如何在Objective-C中访问另一个数组中的数组索引

我有这个数组,我想访问另一个数组中的第一个索引.

(
    (
        1021,
        "String1,
        "<null>",
        "name1, name2",
        P,
        "String2",
        "Link1",
        "String3",
        "String4"
    ),
    (
        1025,
        "String1",
        "<null>",
        "name1, name2"
        P,
        "String2",
        "Link1",
        "String3",
        "String4"
    )
)
Run Code Online (Sandbox Code Playgroud)

我尝试使用此代码的NSLog:

NSLog(@"ID: %@", [[array objectAtIndex:0] objectAtIndex:0]);
Run Code Online (Sandbox Code Playgroud)

但它不起作用.它给我一个错误说:

-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance
Run Code Online (Sandbox Code Playgroud)

我只想在第一个数组的第一个数组中记录值1021.

indexing xcode objective-c nsarray

0
推荐指数
1
解决办法
993
查看次数

componentsSeparatedByString:@""(数组中的每个字符)

我想在一个中添加每个角色NSArray ("123" -> To NSArray with "1","2","3").我测试componentsSeparatedByString:@""componentsSeparatedByString:nil,但它不工作,谁能帮助我?

cocoa objective-c nsstring nsarray

0
推荐指数
1
解决办法
784
查看次数