gpt4 book ai didi

objective-c - 基本的 Objective C 语法问题

转载 作者:行者123 更新时间:2023-11-28 18:27:15 26 4
gpt4 key购买 nike

谁能证实我对这行代码的怀疑。

NSUInteger newPath[] = {[indexPath section],0};

我很确定它是 NSUInteger 的 C 数组。我说得对吗?你甚至可以制作 Objective C 对象的 C 数组吗?

这里是上下文中的代码:

-(UITableViewCellEditingStyle)tableView:(UITableView *) tableViewEditingStyleForRowAtIndexPath:(NSIndexPath*)indexPath{

if ([self isToManyRelationshipSection:[indexPath section]]) {
NSUInteger newPath[] = {[indexPath section],0};
NSIndexPath *row0IndexPath = [NSIndexPath indexPathWithIndexes:newPath length:2];

NSString *rowKey = [rowKeys nestedObjectAtIndexPath:row0IndexPath];
NSString *rowLabel = [rowLabels nestedObjectAtIndexPath:row0IndexPath];
NSMutableSet *rowSet = [managedObject mutableSetValueForKey:rowKey];//!!!: to-many?
NSArray *rowArray = [NSArray arrayByOrderingSet:rowSet byKey:rowLabel ascending:YES];

if ([indexPath row] >= [rowArray count]) {
return UITableViewCellEditingStyleInsert;
}

return UITableViewCellEditingStyleDelete;
}
return UITableViewCellEditingStyleNone;

最佳答案

是的,你是对的。然而……

NSUInteger newPath[] = {[indexPath section],0};
NSIndexPath *row0IndexPath = [NSIndexPath indexPathWithIndexes:newPath length:2];

强烈不鼓励您使用这种格式来创建用于UITableViewNSIndexPathThere's a convenience method to do this 更简单:

NSIndexPath *row0IndexPath = [NSIndexPath indexPathForRow:0 inSection:[indexPath section]];

关于objective-c - 基本的 Objective C 语法问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4684400/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com