Compiler error “expected method not found” when using subscript on NSArray

后端 未结 7 2026
悲哀的现实
悲哀的现实 2020-11-29 04:45

I wrote this simple code to try out the new Objective-C literal syntax for NSArrays:

NSArray *array = @[@"foo"];
NSLog(@"%@",         


        
7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 05:00

    I got the same problem, but then it wasn't b/c of a lacking iOS version.. but it was simply because the original array was set as an NSArray rather than an NSMutableArray. Changing it to NSMutableArray fixed it for me

提交回复
热议问题