automatic-ref-counting

Variable issue during transition from iOS 4 to iOS 5+ARC: “Passing address of non-local object to _autoreleasing parameter for write-back”

房东的猫 提交于 2020-01-16 02:06:10
问题 The "old" way that I was doing this in iOS 4 was by declaring the object in the header file and passing the object for a write-back to handle an error parameter. NSError *error; For reasons beyond my limited knowledge I could not continue this pattern in iOS5 and received the error: "Passing address of non-local object to _autoreleasing parameter for write-back" //Instantiate an instance of AVAudioSession object AVAudioSession *audioSession = [AVAudioSession sharedInstance]; //Setup playback

Variable issue during transition from iOS 4 to iOS 5+ARC: “Passing address of non-local object to _autoreleasing parameter for write-back”

走远了吗. 提交于 2020-01-16 02:06:00
问题 The "old" way that I was doing this in iOS 4 was by declaring the object in the header file and passing the object for a write-back to handle an error parameter. NSError *error; For reasons beyond my limited knowledge I could not continue this pattern in iOS5 and received the error: "Passing address of non-local object to _autoreleasing parameter for write-back" //Instantiate an instance of AVAudioSession object AVAudioSession *audioSession = [AVAudioSession sharedInstance]; //Setup playback

Addressbook linker error: Undefined symbols for architecture i386

风流意气都作罢 提交于 2020-01-15 03:30:09
问题 When I use __bridge_transfer or __bridge : - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person { NSString* nameFirst = (__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty); NSString* nameLast = (__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty); _sight.contactName = [NSString stringWithFormat:@"%@ %@", nameFirst, nameLast]; [self

Why is this TStreamAdapter not released?

感情迁移 提交于 2020-01-14 13:01:50
问题 Compare these two snippets: (d as IPersistStream).Save( TStreamAdapter.Create( TFileStream.Create('test.bin',fmCreate),soOwned),true); (d as IPersistStream).Load( TStreamAdapter.Create( TFileStream.Create('test.bin',fmOpenRead),soOwned)); This fails on the second TFileStream.Create because the first isn't destroyed. This is odd since the parameter has the only reference, I thought it would get destroyed in closing up the Save call. So I tried this: var x:IStream; begin x:=TStreamAdapter

ARC circular reference in objective-c uses delegate

拈花ヽ惹草 提交于 2020-01-13 10:16:12
问题 Hello! I tried to use a delegate in my app. My project uses ARC For example, I have protocol X and two object which uses it. In object B I created an instance for object A and set delegate self (A.delegate = self) In runtime I invoke a method callBack (in this point my delegate object is B ). After that they all execute the -showResult method. At what point is a circular reference formed? I understand that this is a problem with the specifier strong , but I don't understand what time it

ARC equivalent of autorelease?

风流意气都作罢 提交于 2020-01-12 13:34:49
问题 If I have this code, + (MyCustomClass*) myCustomClass { return [[[MyCustomClass alloc] init] autorelease]; } This code guarantees the returning object is autoreleased. What's the equivalent of this in ARC? 回答1: There is no equivalent in ARC, as you don't need to do it yourself. it will happen behind the scenes and you are not allowed to do it your self. You simply use - + (MyCustomClass*) myCustomClass { return [[MyCustomClass alloc] init]; } I suggest you to watch the ARC introduction in the

Core Data attribute changes to nil (ARC related?)

一笑奈何 提交于 2020-01-12 07:30:07
问题 I have some Core Data functionality that was working fine until some recent (seemingly unrelated) changes were made. Now I'm getting problems where all the attributes belonging to a particular NSManagedObject subclass instance are suddenly returning nil. Let's say my NSManagedObject subclass is called Foo and it has only one attribute called value. Once I realised value was somehow becoming nil I went and setup the following category to monitor changes to value. @implementation Foo (Debug) -

SpriteKit not deallocating all used memory

纵饮孤独 提交于 2020-01-12 03:56:08
问题 I have ready many (if not all) articles on SO and other sites about the disasters of dealing with SpriteKit and memory issues. My problem, as many others have had, is after i leave my SpriteKit scene barely any of the memory added during the scene session is released. I've tried to implement all suggested solutions in the articles i've found, including, but not limited to... 1) Confirm the deinit method is called in the SKScene class. 2) Confirm no strong references to the parent VC in the

UINavigation pushing a new root controller

↘锁芯ラ 提交于 2020-01-11 12:05:56
问题 I am trying to push a new root controller to a navigation stack, but using a side reveal menu. My app delegate has the following: welcomeViewController = [[MyWelcomeViewController alloc] initWithNibName:@"MyWelcomeViewController" bundle:nil]; navController = [[UINavigationController alloc] initWithRootViewController:welcomeViewController]; navController.navigationBarHidden = YES; // Then we setup the reveal side view controller with the root view controller as the navigation controller self

What is the correct way of init iVar variables in presence of ARC

跟風遠走 提交于 2020-01-10 20:17:08
问题 Example iVar foo , @property (nonatomic) NSString* foo; // inside .h Option 1 @Synthesize foo; //Inside .m foo = [[NSString alloc] init]; // viewDidLoad method Option 2 @Synthesize foo; //Inside .m self.foo = [[NSString alloc] init]; // viewDidLoad method Option 3 @Synthesize foo = _foo; //Inside .m _foo = [[NSString alloc] init]; // viewDidLoad method Why? At so many places I have seen code which has different ways of doing init an Object in Obj - C but which one is the best practise? 回答1: