日志中的错误:
* 由于未捕获的异常“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 …
尝试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。
有没有其他人看到这个?
这是有效的:
NSObject anObject = [[NSObject alloc] init];
[array1 addObject:anObject];
[array2 addObject:anObject];
Run Code Online (Sandbox Code Playgroud)
我的钱是肯定的,因为我只是添加对同一个对象的引用,或者我错了吗?
我想从a中删除一个特定元素NSMutableArray,我看到NSArray有indexOfObject一个对此非常有用的方法,但NSMutableArray没有.
我目前的方法是使用removeObjectsInArray方法NSMutableArray作为参数传递包含我的object/s的数组.
有没有更好的方法呢?有什么理由NSMutableArray没有这种方法吗?
这真让我抓狂!我一直在崩溃这个错误.以下是我的代码.我试图在我的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) 举个例子,如果我有这个数组:
_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"];但都没有工作.
当我使用来自我所需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) 我有一个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) 我有这个数组,我想访问另一个数组中的第一个索引.
(
(
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.
我想在一个中添加每个角色NSArray ("123" -> To NSArray with "1","2","3").我测试componentsSeparatedByString:@""和componentsSeparatedByString:nil,但它不工作,谁能帮助我?
nsarray ×10
objective-c ×7
ios ×4
iphone ×3
cocoa ×2
xcode ×2
cocoa-touch ×1
core-data ×1
foundation ×1
indexing ×1
memory-leaks ×1
nsstring ×1
object ×1
sorting ×1
swift ×1
xml-parsing ×1