automatic-ref-counting

How to use GCMathParser in iOS 5 application (XCode 4.2) with ARC?

三世轮回 提交于 2019-12-11 19:15:25
问题 After changing - #import <Cocoa/Cocoa.h> to #import <UIKit/UIKit.h> - "pi" to "M_PI" and disabling ARC for the GCMathParser files, I get the following error: (multiple places) Cast of C pointer type "void*" to Objective-C pointer type "GCMathParser*" requires a bridged cast What do I have to do? Thanks 回答1: ARC doesn't let you hide objects behind untyped pointers -- it needs to know which pointers are objects in order to do its magic. If you're dealing with a framework that relies heavily on

does setting an object to nil with ARC cause a release of its properties

删除回忆录丶 提交于 2019-12-11 18:24:33
问题 If I set an object, say a view controller to nil, will its properties like buttons and labels also get released under ARC? What happens in case the properties are of type strong and assign? Also, when not using ARC, in my delloc method, do I only release retain type properties? 回答1: You should read this Apple Memory Management documentation. Basically, it depends. The view controller would be released unless some other instance was retaining it. Then, when it is released, its properties would

Error Message: ARC is required to compile Pushwoosh SDK

牧云@^-^@ 提交于 2019-12-11 18:13:23
问题 I am new in xcode. I got recurring message error when building for testing: *PWRequest.m User defined issues "ARC is required to compile Pushwoosh SDK"* In code it shows: #if ! __has_feature(objc_arc) #error "ARC is required to compile Pushwoosh SDK" #endif I don't understand. I added a new pushwoosh sdk. I thank you very much for your help. 回答1: You can set ARC on a file basis. Go to the BuildPhases->CompileSources. You can select sources there and pass ARC flag. Same as here: How can I

using arc, my ivars are null after init

走远了吗. 提交于 2019-12-11 17:45:01
问题 MOST NEW TESTING: I placed a NSLog(@"%p", self.myArray); after the array assignment and I am seeing a address actually logged.....!?!?! 2012-03-06 01:33:52.618 ArrayTest[9883:f803] 0xae0f160 Seems that Xcode is all wacked out if it cant see the addess of that ivar in either local variables or with the tool tip highlight method... Thoughts? NEWEST TESTING: I created a brand new project. It seems that simple assigning of objects to ivars is not working at all. If I look at the address of

memory management attribute when using Class type property in Objective-C ARC? [duplicate]

孤者浪人 提交于 2019-12-11 17:08:21
问题 This question already has an answer here : Objective-C - Should we use strong, weak or assign for Class-type? (1 answer) Closed last year . Class is a struct pointer, is it a object type or scalar, which I guess is the key to decide to use strong / weak or assign ? 回答1: In Objective-C Class is an object and is instance of a metaclass. It is a retainable object pointer type. Reference: clang.llvm.org also this SO thread. 回答2: import UIKit class Human{ var name:String! var passport:Passport! //

Do I have to get rid of my release statements upon upgrading to ARC?

Deadly 提交于 2019-12-11 15:02:20
问题 New to all this ARC stuff. I've been developing an iOS game using Manual Reference Counting with cocos2d-iphone 1.0.1 this whole time. Recently, upon reading some instructions (http://www.tinytimgames.com/2011/07/22/cocos2d-and-arc/#comment-563567859), I upgraded my project to support Automatic Reference Counting. When I developed using the manual method, I, of course, used release in many places. However, I noticed that I had many memory leaks and I was having a hard time finding all of them

__builtin_va_arg (for pointer to pointer)

浪尽此生 提交于 2019-12-11 14:14:26
问题 I have a code which extracts the arguments of a method. va_list argp2; va_start(argp2, sel); NSURLResponse* obj = va_arg(*argp2,NSURLResponse**); the argp2 contains the arguments for the method [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error] I would like to convert argp2 to get a pointer to response and error objects. Thanks 来源: https://stackoverflow.com/questions/23741425/builtin-va-arg-for-pointer-to-pointer

So what's the deal with ARC and releasing properties/subviews on viewDidUnload

懵懂的女人 提交于 2019-12-11 10:52:42
问题 I'm still learning iOS development and have been working with various tutorials and books. Some pre-ARC, some with ARC. In some cases, we're taught to release all of the properties and subviews of a ViewController on viewDidUnload but in some cases I've been told this is no longer required. Can someone give a definitive answer? In iOS 5+, does one have to do the whole: -(void)viewDidUnload { [super viewDidUnload]; self.photoViewCell = nil; self.photoImageView = nil; self.firstNameTextField =

CFStringRef to NSString ARC leaking. Why?

孤人 提交于 2019-12-11 09:56:50
问题 I have been looking around for the correct way to go from CFStringRef to NSString in ARC to avoid memory leaks and some of the main voted answers suggest: NSString * string = (__bridge NSString *)cfString; I am using that approach here but when profiling the app I still get a memory leak in this small method [see attached image]. So, I am not sure how to fix this. Anybody has the solution to this problem? Thank you So, apparently adding the CFRelease(ext) before the return fixed the leak.

Comparing two strings through a selector: unexpected result

两盒软妹~` 提交于 2019-12-11 09:42:16
问题 I am doing an exercise to learn how to use selectors in Objective-C. In this code I am trying to compare two strings: int main (int argc, const char * argv[]) { @autoreleasepool { SEL selector= @selector(caseInsensitiveCompare:); NSString* str1=@"hello"; NSString* str2=@"hello"; id result=[str1 performSelector: selector withObject: str2]; NSLog(@"%d",[result boolValue]); } return 0; } But it prints zero.Why? Edit: And if I change str2 to @"hell" I get an EXC_BAD_ACCESS. 回答1: The documentation