I’m not so sure this is a dumb newbie question so I kept that out of the subject line ;-) My app has a few objC frameworks that are being bridged in via the bridging header. One issue I’m seeing at runtime has to do with the objC NSData object length property vs. the Swift Data count property.
The line of code from the framework in this case looks like this
if([request.requestBody length] > 0){
and the interface for request object looks like this…
interface AEServiceRequest : NSObject
property(nonatomic, readonly, strong, nullable) NSData *requestBody;
when the app is run and it interrogates the length method (also was .length) the exception thrown below as if the length call did not get converted into count but the NSData object did get converted into Data. Just a guess. Has anyone seen this type of thing in their experience ? Is there a fix for it that I’m missing ?
I add in some NSLogs into the framework code for tracing...
AEDAService: AEService 1.4.2 init started... 2016-08-25 14:12:44.592 AEDemoApp_Swift_OSX[24703:4124653] Entering: _urlRequest 2016-08-25 14:12:44.592 AEDemoApp_Swift_OSX[24703:4124653] Start call: if(request.requestBody.length > 0 2016-08-25 14:12:44.592 AEDemoApp_Swift_OSX[24703:4124653] -[_SwiftValue length]: unrecognized selector sent to instance 0x61800004c480 2016-08-25 14:12:44.593 AEDemoApp_Swift_OSX[24703:4124653] An uncaught exception was raised 2016-08-25 14:12:44.593 AEDemoApp_Swift_OSX[24703:4124653] -[_SwiftValue length]: unrecognized selector sent to instance 0x61800004c480 2016-08-25 14:12:44.593 AEDemoApp_Swift_OSX[24703:4124653] ( 0 CoreFoundation 0x00007fff942d04f2 __exceptionPreprocess + 178 1 libobjc.A.dylib 0x00007fff8c9a873c objc_exception_throw + 48 2 CoreFoundation 0x00007fff9433a1ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
Anyone seen this type of behavior before. BTW Using xCode 8 beta 6 w/ Swift 3