Ios 在类型为';的对象上找不到读取数组元素的预期方法;id<;协议名>';

Ios 在类型为';的对象上找不到读取数组元素的预期方法;id<;协议名>';,ios,objective-c,xcode,xcode9,xcode9.3,Ios,Objective C,Xcode,Xcode9,Xcode9.3,我想更新XCode版本 但在更新时,我收到了几个编译器错误。以下内容与此相同: id objectToDelete=group[index.unsignedIntegerValue] 在“id”类型的对象上找不到读取数组元素的预期方法 id\u非空组 @protocol MyProtocol <NSObject> @property (copy, nonatomic) NSString* name; @property (copy, nonatomic) NSString* id;

我想更新XCode版本

但在更新时,我收到了几个编译器错误。以下内容与此相同:

id objectToDelete=group[index.unsignedIntegerValue]

在“id”类型的对象上找不到读取数组元素的预期方法

id\u非空组

@protocol MyProtocol <NSObject>

@property (copy, nonatomic) NSString* name;
@property (copy, nonatomic) NSString* id;
@property (copy, nonatomic) NSString* internalType;
@property (strong, nonatomic) NSMutableArray<id<SomeAnotherProtocol>>* objects;

- (instancetype)initWithObject:(MyProtocol*)object;
// Search
- (BOOL)isContainsObjectWithID:(NSString*)myID;
- (NSUInteger)indexForObjectID:(NSString*)myID;
- (id<SomeAnotherProtocol>)objectWithID:(NSString*)myID;
- (NSString*)groupID;

@end
@protocol-MyProtocol
@属性(副本,非原子)NSString*名称;
@属性(副本,非原子)NSString*id;
@属性(复制,非原子)NSString*internalType;
@属性(强,非原子)NSMutableArray*对象;
-(instancetype)initWithObject:(MyProtocol*)对象;
//搜寻
-(BOOL)包含id:(NSString*)myID的对象;
-(NSUTEGER)indexForObjectID:(NSString*)myID;
-(id)objectWithID:(NSString*)myID;
-(NSString*)groupID;
@结束
此错误仅出现在XCode 9.3版本上

Does
id objectToDelete=((NSArray*)组)[index.unsignedintegValue]唯一的解决方案?

试试这个:
[group ObjectatinIndexedSubscript:idx]

首先,我假设
group
实际上不是
NSArray
,而是:

id<MyProtocol> _Nonnull group

当然,您需要在任何符合的情况下实现
objectAtIndexedSubscript:
(但似乎已经是这样了,因为在您强制转换它时它就起作用了)。

id objectToDelete=[group-objectAtIndex:index.unsignedIntegerValue]可能也会起作用。@Larme
选择器“objectAtIndex:”没有已知的实例方法。
需要添加关于海报为什么应该尝试该方法的任何信息吗?因为他的项目使用xcode 9.2,但使用xcode 9.3失败。因此,如果
group[…]
有效,并且
objectAtIndex:index
失败,我建议,object
group
的某个地方实现
objectAtIndexedSubscript:
方法。
@protocol MyProtocol <NSObject>
- (id<MyProtocol>)objectAtIndexedSubscript:(NSUInteger)idx;
...