[英]Incompatible integer to pointer conversion with NSArray
我使用以下代碼在標頭中定義數組: @property (strong, nonatomic) NSArray *editContents;
NSArray中的值是使用以下代碼設置的:
self.editContents = @[
@[@-1,@-1],
@[@0,@80],
@[@0,@500],
@[@-1,@-1],
@[@-1,@-1],
@[@-1,@-1],
@[@-1,@-1],
@[@-1,@-1],
@[@-1,@-1],
@[@-1,@-1],
@[@-1,@-1]
];
我在用TableView和TableViewCells做一些奇怪的事情來設置一些值。
但是,問題歸結為IBOutlet中的以下代碼:
self.superController.editContents[self.index.section][self.index.row] = [self.sortInput.text intValue];
您正在使用NSArray
因此無法更改NSArray
的值。請使用NSMutableArray
。但是對於您的代碼,您需要將其轉換為NSNumber
。
self.superController.editContents[self.index.section][self.index.row] = @([self.sortInput.text intValue]);
self.superController.editContents[self.index.section][self.index.row] = @([self.sortInput.text intValue]);
但是,這將不起作用,因為editContents
內的單個數組是NSArray
而不是NSMutableArray
,因此它們是只讀的。 做這個:
@ [[@ [@-1,@ -1] mutableCopy]]
乏味,我知道。 但我沒有其他辦法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.