gpt4 book ai didi

ios - 错误 : Indexing expression is invalid because subscript type 'NSUInteger' is not an integral or objective c pointer type

转载 作者:可可西里 更新时间:2023-11-01 06:20:49 24 4
gpt4 key购买 nike

我有一个名为“rankStrings”的数组,我试图从它的索引处获取数据,如下所示...

NSArray *rankStrings = @[@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10"];

return [rankStrings[self.rank] stringByAppendingString:self.suit];

“等级”声明为...

@property (nonatomic) NSUInteger *rank;

我收到错误消息,“索引表达式无效,因为下标类型‘NSUInteger’不是整数或 Objective-C 指针类型”。

我试过用“NSInteger”或“int”代替“NSUInteger”,但还是一样。

非常感谢任何帮助!!

最佳答案

您正在使用指向 NSUInteger指针,并且该数组需要一个 NSUInteger(原始类型)作为索引。改为这样声明您的属性(property):

@property (nonatomic,assign) NSUInteger rank;

关于ios - 错误 : Indexing expression is invalid because subscript type 'NSUInteger' is not an integral or objective c pointer type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18928930/

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