1

Using [code 1]【 getReturnValue :】 iOS reflection OC object, in the

【iPhone4s + iOS8.4】、【 iphone 4 + iOS7.1】 (crash),
【iPhone6 + iOS9.3】、【 iphone 5 + iOS8.4.1】 (pass),

But i implement the following [code 2] on all of systems test pass, is that a system bug or other reson?

// code 1 
id objcMinor;    
if( !strcmp(minorReturnType, @encode (id)) )   
{  
   [invoMinor getReturnValue:&objcMinor];   
}


// code 2 
void *temp = NULL;   
[objcMinor getReturnValue:&temp];   
id objcMinor = (__bridge id)temp;   


NSMutableDictionary *dic = [NSMutableDictionary dictionary];
[dic setObject:objcMinor forKey:@"minor"];
[[NSUserDefaults standardUserDefaults] setObject:dic forKey:@"test"];   

edit Xcode scheme->run->enable Zombile objects
console output

*** -[CFNumber release]: message sent to deallocated instance 0x7baa7460

crash screenshot :enter image description here

test demo download link https://github.com/leopardpan/IssuesDemo

leopardpan
  • 56
  • 5
  • difference between id and void * http://stackoverflow.com/questions/1304176/objective-c-difference-between-id-and-void – leopardpan Jul 28 '16 at 09:43
  • Someone recommended I use 【__autoreleasing id objcMinor】,I'm not sure the official recommendation should do is to do a good job. – leopardpan Jul 28 '16 at 09:48
  • apple link: https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSInvocation_Class/#//apple_ref/occ/instm/NSInvocation/getReturnValue: – leopardpan Jul 28 '16 at 09:53

0 Answers0