automatic-ref-counting

Alternative to Objective-C objects in structs (ARC)

耗尽温柔 提交于 2019-12-01 20:48:34
I have the following code here that won't run on ARC since it combines Objective-C objects in structs: struct SingleToManyRelation { id singleObject; NSSet* manyObjects; } I know this is reminiscent of Core Data, but that's not the point ;) I am just looking for a solution to implement something like that without having to create a "container" class. Thanks in advance for your advices, Christian Give your objects the __unsafe_unretained attribute and ARC will stop complaining (but keep in mind that they aren't retained! So you have to somehow store a strong relationship to them, if you don't

Issue with NSMakeCollectable when converting to ARC

让人想犯罪 __ 提交于 2019-12-01 18:16:35
I am trying to convert my code to ARC and I have problem with NSMakeCollectable in the ASIRequest library. - (NSString*)encodeURL:(NSString *)string { NSString *newString = NSMakeCollectable([(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding([self stringEncoding])) autorelease]); if (newString) { return newString; } return @""; } It is giving me this error: NSMakeCollectable is unavailable: not available in automatic reference counting . How do I solve this?

MKMapView memory usage steadily increasing

萝らか妹 提交于 2019-12-01 18:03:45
In my app, I've noticed that as I push and pop a view controller containing an MKMapView , memory usage steadily increases. I've determined that there is a problem with MapKit itself, not my code, though. I made a test project containing simply a navigation controller in which I repeatedly can push and pop a view controller containing nothing but a map view- no annotations or overlays. As I push and pop the view controller over and over, memory usage increases by about .6 MB each push/pop cycle. Any thoughts as to why this is happening? I am using ARC. Thanks! Edit: I've done some testing in

ARC behavior within a recursive block

被刻印的时光 ゝ 提交于 2019-12-01 18:02:16
问题 I've made these two utility funcions: + (void)dispatch:(void (^)())f afterDelay:(float)delay { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay*NSEC_PER_SEC)), dispatch_get_main_queue(), f); } + (void)dispatch:(void (^)())f withInterval:(float)delay { void (^_f)() = nil; // <-- A _f = ^{ f(); [self dispatch:_f afterDelay:delay]; // <-- B }; [self dispatch:_f afterDelay:delay]; } The idea is that you would be able to call: [self dispatch: block afterDelay: delay ]; - to get a

MKMapView memory usage steadily increasing

蹲街弑〆低调 提交于 2019-12-01 17:52:50
问题 In my app, I've noticed that as I push and pop a view controller containing an MKMapView , memory usage steadily increases. I've determined that there is a problem with MapKit itself, not my code, though. I made a test project containing simply a navigation controller in which I repeatedly can push and pop a view controller containing nothing but a map view- no annotations or overlays. As I push and pop the view controller over and over, memory usage increases by about .6 MB each push/pop

iPhone ARC & Facebook SDK

我是研究僧i 提交于 2019-12-01 17:34:33
I'm getting all kinds of build errors with Facebook's SDK because my app uses ARC. I try to remove the Facebook files from the compiler to avoid this, but I get an Apple Mach-O error when I remove the Facebook.m file. If I put that back in the compile sources, I get the ARC errors. Anyone run into this? btype Do you exclude them from arc with Compiler flag -fno-objc-arc ? You can see a Answer here And this is why distributing a shared library by copy and pasting files is bad . A library should be distributed as it's own Xcode projects with a static library target, so that the build setting

How do I correct the “Undefined symbols for architecture i386: ”_main\" linking issue?

随声附和 提交于 2019-12-01 17:28:22
I am trying to use the KeyChainitemwrapper provided by apple. My project is using ARC but I have turned of ARC on KeyChainitemwrapper.m. I linked the 'security.framework' framework to my project. I am getting this linking issue: Undefined symbols for architecture i386: "_main", referenced from: start in crt1.10.6.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) I am new to ios development but my guess is that the problem has to do with the fact that the simulator is trying to compile my source targeting i386 rather

Want to perform action when __weak ivar is niled

寵の児 提交于 2019-12-01 16:54:36
I have a @class Foo which contains a __weak id bar ivar. Several actions from methods in different classes can cause the object to disappear and thus get bar niled. I want to perform an action when the ivar is automatically niled by ARC. If possible, I would want to avoid turning bar into a property or using Key-Value Observing. Is this even possible? If not, can KVO be used against non-property ivars? I was led here by a duplicate question, here is what I answered: You can't do that with KVO, but you can still get a notification and emulate this by associating an object with your iVar using

Swift: CGPathRelease and ARC

柔情痞子 提交于 2019-12-01 16:18:57
Just updated to Xcode Beta 4, and noticed the following compiler error with my code below: var path = CGPathCreateMutable() ... CGPathRelease(path) 'CGPathRelease' is unavailable: Core Foundation objects are automatically memory managed So do I simply just remove my release calls and everything should be fine? Or is there something more I'm missing? And are there any special cases I should be aware of with ARC? The Working with Cocoa Data Types section of Using Swift with Cocoa and Objective-C says (emphasis mine): Core Foundation objects returned from annotated APIs are automatically memory

iPhone ARC & Facebook SDK

半城伤御伤魂 提交于 2019-12-01 16:12:35
问题 I'm getting all kinds of build errors with Facebook's SDK because my app uses ARC. I try to remove the Facebook files from the compiler to avoid this, but I get an Apple Mach-O error when I remove the Facebook.m file. If I put that back in the compile sources, I get the ARC errors. Anyone run into this? 回答1: Do you exclude them from arc with Compiler flag -fno-objc-arc ? You can see a Answer here 回答2: And this is why distributing a shared library by copy and pasting files is bad . A library