automatic-ref-counting

Why ARC doesn't release memory when popViewControllerAnimated is called

百般思念 提交于 2019-12-11 08:37:34
问题 my project use ARC , and when i have to show a view with navigation controller i do this: ShareViewController_iPhone *share = [[ShareViewController_iPhone alloc] initWithNibName:@"ShareViewController_iPhone" bundle:nil]; [self.navigationController pushViewController:share animated:YES]; and i can see in xcode that the memory is increased of a certain value, then when i dismiss the view i do this: [self.navigationController popViewControllerAnimated:YES]; but when the view is closed, the

Core Data: Custom Setter Which Does Cascading Calculation Failing

爷,独闯天下 提交于 2019-12-11 08:28:20
问题 I have a class called Location with the following automatically generated declaration, #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @interface Location : NSManagedObject @property (nonatomic, retain) NSNumber * cosRadLat; @property (nonatomic, retain) NSNumber * latitude; @property (nonatomic, retain) NSNumber * longitude; @property (nonatomic, retain) NSNumber * radLat; @property (nonatomic, retain) NSNumber * radLng; @property (nonatomic, retain) NSNumber * sinRadLat;

ARC - popviewController/DismissViewController

久未见 提交于 2019-12-11 07:19:40
问题 I have some doubts with the ARC. In ARC: When a viewcontroller is dismissed by using the dismissViewController/popViewController, Will it's allocated memory automatically get released? What will happen when there is an asynchronous NSURLConnection is running and before that operation completed, viewcontroller got dismissed? Thank you 回答1: When you dismiss a view controller (or pop it), it will be deallocated if you didn't make any strong pointers to it (that controller is retained by the

ARC releasing ViewController prematurely

不打扰是莪最后的温柔 提交于 2019-12-11 05:58:58
问题 I am new to ARC and I have been playing with it for less than a week. What I am trying to do is very basic. I have a view controller that displays a button. When I click the button, the corresponding selector needs to be called. However, with ARC, the application crashed with an EXC_BAD_ACCESS message. Below is the code from my MainViewController - (void)loadView { [super loadView]; UIButton *testButton=[UIButton buttonWithType:UIButtonTypeRoundedRect]; [testButton setFrame:CGRectMake(80,50

I keep getting an arc error when building

◇◆丶佛笑我妖孽 提交于 2019-12-11 05:53:52
问题 EDIT My problem was that I didn't link a class to my project. I am working on an app that is basically a terminal app. When I try to build it I'm getting a build error. Ld /Users/evanstoddard/Library/Developer/Xcode/DerivedData/Highjack-anstcjvykrnniwbltvijvyvexirq/Build/Products/Debug-iphonesimulator/Highjack.app/Highjack normal i386 cd /Users/evanstoddard/Desktop/Highjack setenv IPHONEOS_DEPLOYMENT_TARGET 6.0 setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator

iOS 5 ARC lazy image loading library

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 05:32:37
问题 Is there an iOS 5 arc compatible lazy Image loading library? I've not found one. My next thought is to make EGOlazyloading a compiled library and link it to my project. Would that work? Any pointers on going about? Thanks! 回答1: I wrote one. You can download it here: https://github.com/nicklockwood/AsyncImageView Alternatively, if you do want to use EGO, or some other library, select Edit>Refactor>Convert to ARC and in the dialog that comes up there's a little drop down to select which files

EXC_ARM_DA_ALIGN error when running on a device

别等时光非礼了梦想. 提交于 2019-12-11 05:30:07
问题 Why is this code running on the simulator and crashing on a real device? I have a very simple code that draws a circle. The code subclasses UIView and runs fine on the Simulator (both for iOS 5.1 and iOS 6.0). Circle.h #import <UIKit/UIKit.h> @interface Circle : UIView @end Circle.m #import "Circle.h" @implementation Circle -(CGPathRef) circlePath{ UIBezierPath *path = [UIBezierPath bezierPath]; [path addArcWithCenter:self.center radius:10.0 startAngle:0.0 endAngle:360.0 clockwise:YES];

Zombie when calling completion block in background thread

旧巷老猫 提交于 2019-12-11 05:08:56
问题 I pass a completion block to my method, this completion block will be called in the background when a network request is finished. Unfortunately, if the calling object is deallocated in the meantime, the app crashes: ViewController (which may be deallocated because it's popped from the navigation stack) code: __unsafe_unretained ViewController *weakSelf = self; [[URLRequester instance] sendUrl:url successBlock:^(id JSON) { [weakSelf webserviceCallReturned:JSON]; }]; URLRequester-Code (made

obj-c weak self in a block: why the 2nd one doesn't need a weak self inside in two similar cases

懵懂的女人 提交于 2019-12-11 04:58:41
问题 I finally found my memory bug is caused by referring self strongly in a block. But I don't know why in a similar case, the weak is not needed: I have a CameraCaptureManager class doing image capture tasks, and a CameraViewController has a strong property of this manager. The manager has weak delegate property pointing back to the controller. This is where I must use weakSelf in the manager, otherwise -(void)dealloc won't be called: // in CameraCaptureManager __weak CameraCaptureManager

How do UIAlertView or UIActionSheet handle retaining/releasing themselves under ARC?

孤街醉人 提交于 2019-12-11 04:18:41
问题 I want to create a similar class to UIAlertView which doesn't require a strong ivar. For example, with UIAlertView, I can do the following in one of my UIViewController's methods: UIAlertView *alertView = [[UIActionSheet alloc] initWithTitle:nil message:@"Foo" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; [alertView show]; ... and the actionSheet will not be dealloced until it is no longer visible. If I were to try to do the same thing: MYAlertView *myAlertView = [