automatic-ref-counting

Avoid Retain Cycles, NSNotificationCenter?

廉价感情. 提交于 2020-01-24 04:29:06
问题 Will this category method allow me to avoid additional retains on NSNotificationCenter observers? #import "NSNotificationCenter+Util.h" @implementation NSNotificationCenter (Util) - (void)addWeakObserver:(nonnull NSObject*)observer selector:(nonnull SEL)aSelector name:(nullable NSString *)aName object:(nullable id)anObject { __weak NSObject *weakObserver = observer; [self addObserver:weakObserver selector:aSelector name:aName object:anObject]; } @end The goal is to have the object die without

Does iOS 4.3 support ARC

和自甴很熟 提交于 2020-01-23 17:52:06
问题 I tried googling but i was unable to locate the Apples Documentation where they say that ARC - automatic reference counting supports for iOS 4.3. Can someone tell me if this is true ? if so can you post me a link to apples documentation where it says so. 回答1: Transitioning to ARC: ARC is supported in Xcode 4.2 for Mac OS X v10.6 and v10.7 (64-bit applications) and for iOS 4 and iOS 5. Weak references are not supported in Mac OS X v10.6 and iOS 4. 回答2: Though ARC is in the new features list of

Enable ARC for theos build system

ⅰ亾dé卋堺 提交于 2020-01-22 16:08:26
问题 I'm currently using the theos build system to write applications and tweaks for jailbroken iPhones. Is there a way for me to enable automatic reference counting for specific projects with theos? I've Googled and tried to decipher the theos makefiles, but I haven't been able to find anything. 回答1: See https://github.com/Maxner/BrightnessFix/blob/master/Makefile ARCHS=armv7 armv7s TARGET_IPHONEOS_DEPLOYMENT_VERSION = 6.0 TARGET_CC = xcrun -sdk iphoneos clang TARGET_CXX = xcrun -sdk iphoneos

memory not releasing with ARC and storyboard in iOS 5.1

我们两清 提交于 2020-01-21 08:29:13
问题 i'm cracking my head on memory issues with my app, the app are working fine except that it will crash once it hit low memory warning and are very very very laggy when using it for 10 to 20 minutes. EDIT: how to poptoviewcontroller? introvideo-> welcomeview & tutorialview-> mainviewcontroller-> scannerviewcontoller-> questionview ->(if answer correct -> correctView) else ->wrongView how do i pop back to mainView controller ? the below code are to solve adding view controller to the

Objective-C: ARC forbids explicit message send of 'retain'

↘锁芯ラ 提交于 2020-01-20 05:47:27
问题 I'm new to Objective-C, I try to port an old Objective-C project written in an older version of Objective-C to the new one, but I'm getting the following compiler error: ARC forbids explicit message send of 'retain' in color = [aColor retain]; or color = [[NSColor blackColor] retain]; I was reading about the new automatic reference counting that clang is using now. I have also tried to use Xcode's refactor function but with no luck... What is the proper Objective-C code that need to replace

performSelector ARC warning [duplicate]

依然范特西╮ 提交于 2020-01-19 05:04:20
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: performSelector may cause a leak because its selector is unknown I have this code in non-ARC that works without errors or warnings: - (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents { // Only care about value changed controlEvent _target = target; _action = action; } - (void)setValue:(float)value { if (value > _maximumValue) { value = _maximumValue; } else if (value

iOS project compilation

左心房为你撑大大i 提交于 2020-01-17 05:45:47
问题 I am working on a project accessing web service. I found a project http://d1xzuxjlafny7l.cloudfront.net/downloads/PromoTest.zip The above code include JSON library [project setting compiler = LLVM 4.2] And I tried to use partial code of that project in my project. So I copied the JSON library into my project [my project uses Apple LLVM 3.1] and then some error show up eg. SBJsonStreamWriterState **states; //error:Pointer to non-const type "SBJsonStreamWriterState *" with no explicit ownership

Why can a weak member be nulled in an instance method before the method is finished?

只愿长相守 提交于 2020-01-16 19:15:34
问题 And why can it vary between Debug/Release/Simulator/Device combinations? (Sample code below.) I inherited some code that "works" in the simulator and on devices in Debug, but not on a device in Release (used to with last LLVM). It's related to ARC and a weak property (which should have been strong), but I don't understand fully what's happening and am hoping someone can explain it to me and why it varies between Debug/Release/Device/Simulator. I created a simple sample project that

Followup to returning nil from a [[class alloc] init]

主宰稳场 提交于 2020-01-16 04:42:26
问题 As follow-up of sorts to Is returning nil from a [[class alloc] init] considered good practice?, there's a case that I haven't seen any discussed much: what to do with an init that fails some preconditions before it can call the next init? Example, suppose in this initWithStuff: method being passed nil or in general having no value to pass to initWithValue: is an absolute failure and we definitely want to return nil. - (id)initWithStuff:(Stuff *)inStuff { if (!inStuff || ![inStuff

UIPopover on ARC

杀马特。学长 韩版系。学妹 提交于 2020-01-16 03:58:07
问题 I am using ARC on an iPad app with the code below, the popover flashes on the screen, but doesn't stay. What I am doing wrong? Please help - (IBAction)photoLibraryAction:(id)sender { UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; [imagePicker setDelegate:self]; UIPopoverController *pop1 = [[UIPopoverController alloc] initWithContentViewController:imagePicker]; [pop1 setDelegate:self]; [pop1 presentPopoverFromBarButtonItem:sender permittedArrowDirections