automatic-ref-counting

Why should I prefer the unsafe_unretained qualifier over assign for weak referencing properties? [duplicate]

落花浮王杯 提交于 2019-12-03 21:37:15
Possible Duplicate: using ARC, lifetime qualifier assign and unsafe_unretained What's the difference between the two? @property(unsafe_unretained) MyClass *delegate; @property(assign) MyClass *delegate; Both are non-zeroing weak references, right? So is there any reason why I should write the longer and harder to read unsafe_unretained instead of assign ? Note: I know there is weak which is a zeroing reference. But it's only iOS >= 5. In a property accessor, yes those are the same. assign properties will map to unsafe_unretained for this case. But consider writing the ivar manually rather than

init] in automatic reference counting

倾然丶 夕夏残阳落幕 提交于 2019-12-03 21:16:37
I know that I am suppose to use: ObjectClass *tmpObject = [[ObjectClass alloc] init]; realObject = tmpObject; [tmpObject release] to initialise realObject (where realObject is an object within a class) But now with ARC mode, releasing is automatic, do i still need to use this technique? Can I simply use realObject = [[ObjectClass alloc] init]; ? If not is there any specific reason why it would leak? Thanks As Spencer said, if you compile with ARC enabled, you cannot call release at all. It is an error to do so and the compiler takes care of it for you. However: ObjectClass *tmpObject = [

Memory problems when pushing many view controllers on UINavigationController

懵懂的女人 提交于 2019-12-03 20:15:20
I'm making an interactive book for the iPad and am using UINavigationController to implement the navigation between a page and the next. When a user turns the page, the next page is pushed on top of the navigation stack. I'm now 15 pages into the app, and the app crashes when I try to go from page 14 to page 15. No error message in the console, nothing in the device's crash logs neither. Each view controller's scene in the storyboard has UIImageViews displaying images that are between 5MB and 20MB. The view controllers' viewDidLoad method is called just once. The total size of all the app's

ARC error when declaring delegate ivar

有些话、适合烂在心里 提交于 2019-12-03 19:44:23
问题 I am using ARC (no, this is not NDA). I am declaring my ivar in my interface with id itemDelegate; I then declare the property: @property (nonatomic, weak) id<mySecretDelegateYouAreNotSupposedToSeeOnSO> itemDelegate; (with weak instead of assign because of ARC) In my implementation file I simply synthesize it: @synthesize itemDelegate; However, I am getting the error: "Existing ivar 'ItemDelegate' for _weak property 'itemDelegate' must be _weak". Anyone know what's wrong? Thanks for your help

Property 'x' not found on object of type 'y *' error only with ARC

≡放荡痞女 提交于 2019-12-03 18:18:35
问题 This error very strange. I have a bunch of properties in app delegate which I have no problem to access. My code worked fine without ARC, but when I turned on ARC I receive this very strange error. Property 'navigationController' not found on object of type 'AppDelegate *' A bunch of other properties work just fine except this. I already clean everything and restarted Xcode. Here is the code: AppDelegate.h: @interface AppDelegate : UIResponder <UINavigationControllerDelegate> {

Lifetime of weak local variables with ARC

家住魔仙堡 提交于 2019-12-03 18:05:26
问题 If I have a piece of code that looks like this: - (void)testSomething { __weak NSString *str = [[NSString alloc] initWithFormat:@"%@", [NSDate date]]; NSLog(@"%@", str); } the output will be (null) because there are no strong references to str and it will be immediately released after I allocate it. This makes sense and is spelled out in the Transitioning to ARC guide. If my code looks like this: - (void)testSomething { __weak NSString *str = [NSString stringWithFormat:@"%@", [NSDate date]];

ld: duplicate symbol _objc_retainedObject on iOS 4.3 , but not on iOS 5.0

纵饮孤独 提交于 2019-12-03 17:39:47
问题 Some background - I've built a custom Framework using Diney's guide at http://db-in.com/blog/2011/07/universal-framework-iphone-ios-2-0/ Its built for both armv6 / armv7 , its an ARC-based framework, compiled with a depolyment target of 4.3. When i put the resulting framework in a 5.0 project it works great, but when i put it in a 4.3 project (ARC or non-arc, doesnt matter), i get the following which i can't really understand ... I've also tried adding libarclite.a manually but it didn't

Mac App Store: Giving up 32 bit support in favor for ARC, will existing users of 32 bit version see an update message?

醉酒当歌 提交于 2019-12-03 17:23:28
I'm considering dropping 32-bit support for in favor for Automatic Reference Counting (which is only supported for 64 bit binaries). I'd like to avoid these two scenarios with the Mac App Store: For a user of an old 32-bit Mac : who did purchase the previous version with 32-bit support: Will they see an update message for the app in the Mac App Store? If so, the (now 64 bit only) update would not work for him/her. who has not purchased the app before: will they be able to purchase the app although it will not run on their system? ARC 64 bit only: http://developer.apple.com/library/mac/

[CFNumber release]: message sent to deallocated instance

丶灬走出姿态 提交于 2019-12-03 16:04:18
The code below returns the following error when I log/request values from the History Core Data object: -[CFNumber release]: message sent to deallocated instance 0x17ea2a90 I originally thought there was an issue elsewhere and have spent countless hours attempting to debug this to no luck. After further testing, I have pinpointed the crash to requesting certain values from the History Core Data object. Can anyone see any issues to why the object values are being deallocated? [[DocumentHandler sharedDocumentHandler] performWithDocument:^(UIManagedDocument *document) { if(!self.document) { self

Do I need ARC keywords for properties that I don't synthesize?

对着背影说爱祢 提交于 2019-12-03 15:50:31
I have a property that I do not synthesize, instead I create a getter and setter myself. Therefore, the ARC keywords (strong or weak) have no meaning, I assume, so I eliminate them. This works fine on Xcode 4.3, but when my coworker opens them on XCode 4.2 the compiler complains that there is no strong/weak keyword, so I instructed him to meaninglessly enter the keyword back in again. Which is correct (with or without keywords)? To be clear: I have a property like this @property (nonatomic) NSString *foo and in the .m file I implement -(NSString *)foo and -(void)setFoo:(NSString *)foo and do