automatic-ref-counting

[CFNumber release]: message sent to deallocated instance

廉价感情. 提交于 2019-12-05 00:02:51
问题 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

In iOS, using ARC, is it sufficient to set all ivars and properties to nil, and release context, image, color space in viewDidUnload?

只谈情不闲聊 提交于 2019-12-04 22:49:31
问题 For iOS apps, using ARC, do we typically release these in viewDidUnload ? set all instance variables to nil set all properties to nil Release any context using CGContextRelease , CGImage with CGImageRelease , and color space with CGColorSpaceRelease (releasing any non object) no special attention needed for NSMutableArray of NSSet elements: just set the reference to NSMutableArray and NSSet to nil, and each element will be automatically released. Will doing these handle most memory release

Is cleaning up strong references in deinit a correct pattern?

前提是你 提交于 2019-12-04 21:14:30
There are several resources ( blog , SO question , plus I've seen it used everywhere) that recommend removing an observer from the NotificationCenter in the deinit of the UIViewController , e.g.: deinit { NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillShow, object: nil) NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillHide, object: nil) } Now while according to another blog entry I don't have to care about removing an observer from NotificationCenter since it uses weak references, I've seen the same pattern used

Using ARC and UITableViewController is throwing Observation info was leaked, and may even become mistakenly attached to some other object

天涯浪子 提交于 2019-12-04 20:57:05
I cannot seem to figure out what to do to resolve this error that I am receiving. I click on a cell which pops a new UITableViewController onto the stack. Once I hit the back button on the Navigation UI when in this controller I receive this error in the debugger but there doesn't seem to be any issue with the app as it doesn't crash or hang and still works fine. An instance 0x79a8400 of class UITableView was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on

objc_release EXC_BAD_ACCESS

血红的双手。 提交于 2019-12-04 19:34:37
Unable to determine what is going on with this error. I am uploading a file in multiple segments. I have threaded my api calls into 7 concurrent threads. Here is the assembly code that it stops at. Here is my printed stack trace Finally the Stack window I do not have any DISPATCH_QUEUE_PRIORITY_LOW except for a #define for dispatch_get_low() and I do not have any calls to dispatch_get_low() as a little background, I am developing my app from xcode 4.4 and recently installed GM Seed 4.5 to test on ios 6. All of my code is still ios5 and this bug plagued me before and after the update of xcode.

Can a custom xcode template partially and selectively enable ARC (Automatic Reference Counting)?

拟墨画扇 提交于 2019-12-04 19:20:39
Problem: A library I use won't support ARC (Automatic Reference Counting). Background (for those unfamiliar to ARC): http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/_index.html Manual Solution: Add the -fno-objc-arc option for each implementation file of the library, and otherwise use ARC normally in my application code. Observation: The following template file can be copied and most likely be used to either turn ARC completely ON or OFF (without adding the compiler flags above -- the in-between solution that I need): "/Developer/Platforms/iPhoneOS

Private properties vs instance variables in ARC [duplicate]

。_饼干妹妹 提交于 2019-12-04 18:21:56
This question already has an answer here : Best way of declaring private variables in cocoa (1 answer) Closed 6 years ago . Having ARC enabled for an iOS app, if I want a class to have a private value/object, it should be better to declare this: // .m file @interface MyClass () @property (strong, nonatomic) NSString *name; @end or this?: @implementation MyClass { NSString *name; } What memory management considerations should I have? Thanks! You can use either approach. In the first case you are declaring a private property--which has some benefits. For instance you could expose that private

Two weak variables referencing each other in Swift?

六眼飞鱼酱① 提交于 2019-12-04 17:55:11
问题 I'm making another attempt today to try to understand retain cycles and weak references in Swift. Reading through the documentation, I saw the following code example where one of the referencing variables is marked as weak to prevent a retain cycle: class Person { let name: String init(name: String) { self.name = name } var apartment: Apartment? deinit { print("\(name) is being deinitialized") } } class Apartment { let unit: String init(unit: String) { self.unit = unit } weak var tenant:

Objective-C classes in structs with ARC

蹲街弑〆低调 提交于 2019-12-04 17:48:27
问题 I tried making a struct with classes in it like: struct my_struct { NSString *string; // more fields }; To my surprise, Objective-C++ allowed this with ARC enabled. How will it manage the string? It can easily retain in each assignment but release is the problem. It can add a destructor with release in it, but this will make the struct non-trivial. It can also make this not retain or release, but to do so there should be unsafe_unretained. From my observation nothing crashes when using this,

ARC forbids synthesizing a property with unspecified ownership or storage

走远了吗. 提交于 2019-12-04 16:45:41
问题 I've created a @property of UIColor , @property (nonatomic) UIColor *color; and then I tried to synthesize it: @synthesize color = _color; but I receive an error: ARC forbids synthesizing a property of Objective-C object with unspecified ownership or storage attribute What does that mean? All I'm trying to do is to create a property for a UIColor object which changes color. 回答1: Change your property declaration to: @property (nonatomic,strong) UIColor *color; so that ARC knows it should be