Re: NSArray's objectAtIndex compiles to objectAtIndexedSubscript?
Re: NSArray's objectAtIndex compiles to objectAtIndexedSubscript?
- Subject: Re: NSArray's objectAtIndex compiles to objectAtIndexedSubscript?
- From: Bill Cheeseman <email@hidden>
- Date: Sun, 09 Mar 2014 08:21:13 -0400
On Mar 7, 2014, at 10:49 AM, Jens Alfke <email@hidden> wrote:
> On Mar 7, 2014, at 4:54 AM, Bill Cheeseman <email@hidden> wrote:
>
>> However, when I run it on Mac OS X 10.7 Lion, I get a runtime error claiming it encountered an invalid argument, namely, the unrecognized selector -objectAtIndexedSubscript:. The NSArray Class Reference notes that -objectAtIndexedSubscript: is available only in OS X 10.8 and later, and that it is "identical to objectAtIndex:". Of course, -objectAtIndex: still exists in the 10.9 API, and it is not marked as deprecated.
>> It appears, therefore, that the compiler generated a call to -objectAtIndexedSubscript: even though my source specifies -objectAtIndex: and a deployment version of 10.7.
>
> Backtrace, please? It’s possible it wasn’t that exact -objectAtIndex: call that raised the exception.
The relevant part of the crash log is reproduced below. You see that the crash occurred in a call to +[PFUIElement QSWStandardizedOperatingSystemVersion]. PFUIElement is a class in the PFAssistive framework that I wrote which has been in use in several of my commercial products for more than 10 years, updated often. The relevant parts of the framework's +initialize and +QSWStandardizedOperatingSystemVersion class methods will be reproduced in a separate message in a moment. You will see that the call to QSWStandardizedOperatingSystemVersion comes at the beginning of +Initialize, and just a little way into QSWStandardizedOperatingSystemVersion it calls -objectAtIndex:.
Application Specific Information:
objc[210]: garbage collection is OFF
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM objectAtIndexedSubscript:]: unrecognized selector sent to instance 0x7ff769c1ee10'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff91e6bf56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff9a17dd5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff91ef81be -[NSObject doesNotRecognizeSelector:] + 190
3 CoreFoundation 0x00007fff91e58e23 ___forwarding___ + 371
4 CoreFoundation 0x00007fff91e58c38 _CF_forwarding_prep_0 + 232
5 PFAssistive 0x00000001016bd3a7 +[PFUIElement QSWStandardizedOperatingSystemVersion] + 304
6 PFAssistive 0x00000001016bc1d0 +[PFUIElement initialize] + 72
7 libobjc.A.dylib 0x00007fff9a173662 _class_initialize + 320
8 libobjc.A.dylib 0x00007fff9a17355f _class_initialize + 61
9 libobjc.A.dylib 0x00007fff9a173517 prepareForMethodLookup + 237
10 libobjc.A.dylib 0x00007fff9a1732bb lookUpMethod + 63
11 libobjc.A.dylib 0x00007fff9a170f3c objc_msgSend + 188
12 libobjc.A.dylib 0x00007fff9a1706ca call_load_methods + 161
13 libobjc.A.dylib 0x00007fff9a17036b load_images + 233
14 ??? 0x00007fff6125a973 0x0 + 140734823246195
15 ??? 0x00007fff612662cd 0x0 + 140734823293645
16 ??? 0x00007fff6126627d 0x0 + 140734823293565
17 ??? 0x00007fff612670b7 0x0 + 140734823297207
18 ??? 0x00007fff6125c4dd 0x0 + 140734823253213
19 ??? 0x00007fff6126060b 0x0 + 140734823269899
20 ??? 0x00007fff6125a059 0x0 + 140734823243865
--
Bill Cheeseman - email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden