automatic-ref-counting

iPhone SIGSEGV crash with any level of Optimization using ARC+ASIHTTPRequest

China☆狼群 提交于 2019-12-10 23:57:35
问题 I currently use ASIHTTPRequest for synchronous requests I recently refactored my code to comply with ARC and omit the ASIHTTPRequest class using the compiler flag -fno-objc-arc I have a _mh_execute_header SIGSEGV crash when I use any type of optimization While turning off all optimization allows my app to run - I need to be able to optimize the app using the iOS default settings which use Fastest, Smallest [-Os] Since this is a memory related issue and since the only manually managed memory

Application size with loading Apple MAP

╄→гoц情女王★ 提交于 2019-12-10 23:37:46
问题 I am struggling with a problem that looks like simple but it is making the app run size to 30-35 MB. The app is ARC enabled. Here is the scenario. 1) I invoke a UIViewcontroller from within my method (the viewController instance is local to the method)& after pushing it to NavigationController I am setting the local instance as nil. btMapViewController *routeMap = [[btMapViewController alloc]init]; [routeMap setSourcLocation:[txtsource text]]; [routeMap setDestinationLocation:[txtDestination

Strange “zombie” in forwardInvocation: + getArgument:atIndex methods

自闭症网瘾萝莉.ら 提交于 2019-12-10 22:09:59
问题 Here is part from my code: - (void)viewDidLoad { [super viewDidLoad]; CGRect frame = [[UIScreen mainScreen] bounds]; _webView = [[UIWebView alloc] initWithFrame:frame]; [_webView setHidden:NO]; [self.view addSubview:_webView]; _vk = [[DPVkontakteCommunicator alloc] initWithWebView:_webView]; DPVkontakteUserAccount *user; NSString *accessToken = [[NSUserDefaults standardUserDefaults] objectForKey:@"accessToken"]; NSInteger userId = [[[NSUserDefaults standardUserDefaults] objectForKey:@"userId"

Unowned Reference causes leak , weak doesn't

孤街浪徒 提交于 2019-12-10 22:06:32
问题 I'm experiencing some kind of memory management issue. I have a subclass of UIViewController and I set its view manually in order to have a reference back to the viewController and to avoid reference cycle I use weak/unowned . Now the problem is , if I use unowned I have a memory leak but if I use weak I don't have one. I can't figure out why this happens? update: It seems like it's a bug. console output: removing vc view Controller deinitialized custom view deinitialized I'm using xcode 8.3

Using a factory method to set a __weak variable seems to keep the object alive too long

∥☆過路亽.° 提交于 2019-12-10 21:59:29
问题 I've created a Person class, of which I instantiate two objects: int main(int argc, const char * argv[]) { @autoreleasepool { Person * __weak pweak = [Person new]; Person *p = [Person personWithName:@"Strong" lastName:nil dateOfBirth:nil]; } return 0; } The Person class overrides its dealloc method, so that it prints the name of the Person being deallocated. Everything goes as expected, the weak variable doesn't keep the Person instance alive, I see this in the log ("John" is the default name

Missing bridge cast causes error in preprocessed source but not in real source

心不动则不痛 提交于 2019-12-10 20:07:36
问题 To compile a source file, clang preprocesses it at first and then compiles it. So if I run clang -E , I should get a preprocessed file, that can be compiled with clang -c . But the following code doesn't compile after preprocessing it. int main(int argc, char * argv[]) { NSString* foo = @"bar"; CFStringRef urlString = CFURLCreateStringByAddingPercentEscapes( NULL, (CFStringRef)foo, NULL, (CFStringRef)@"", kCFStringEncodingUTF8 ); CFRelease(urlString); return 0; } It compiles with clang -c

Cast NSURL ** to CFURLRef *

ε祈祈猫儿з 提交于 2019-12-10 18:56:18
问题 How can I compile the following code using ARC? int main() { NSURL *url = [NSURL new]; NSURL * __strong *urlPointer = &url; CFURLRef *cfPointer = (__bridge CFURLRef *)urlPointer; geturl(cfPointer); NSLog(@"Got URL: %@", url); return 0; } I get the following error: Incompatible types casting 'NSURL *__strong *' to 'CFURLRef *' (aka 'const struct __CFURL **') with a __bridge cast I know that CFURLRef is already a pointer, so CFURLRef * is a pointer to a pointer, however the external function I

object_getInstanceVariable/object_setInstanceVariable in ARC

假如想象 提交于 2019-12-10 18:19:36
问题 Why are the Objective-C runtime methods object_getInstanceVariable and object_setInstanceVariable are not available under Automatic Reference Counting and what can I do about it? object_getInstanceVariable is buggy when the instance variable's size is larger than the development target's pointer size. How can I get around this? 回答1: Use the valueForKey: and setValue:forKey: methods instead. These allow you to read/write any instance variable of an object. For primitive-typed instance

iOS - ViewController not being released when popped under ARC

不打扰是莪最后的温柔 提交于 2019-12-10 18:18:09
问题 I have a UITabBarController as my main base view controller. Under the first tab, I have a UINavigationController which of course has a rootViewController associated with it, call it vcA . vcA has a button which fires a child view controller, vcB using the code: [self performSegueWithIdentifier:@"PlacesDetailsSegue" sender:senderDictionary]; This appears to work, and I see in instruments that new allocations for vcB are occurring. When I pop the view controller back to vcA , everything looks

ARC/ObjC++: C++ object inside an ObjC container

拟墨画扇 提交于 2019-12-10 18:14:14
问题 Consider: class SomeCppClass { public: SomeCppClass() {} ; ~SomeCppClass() {} ; } ; @interface Test1 : NSObject - (id) init ; @property (strong, nonatomic) NSMutableArray * container ; @end @implementation Test1 @synthesize container ; - (id) init { if (self = [super init]) { container = [NSMutableArray arrayWithCapacity:10] ; [container addObject:[NSValue valueWithPointer:new SomeCppClass()]] ; } return self ; } - (void) dealloc { for (NSValue * v in container) { SomeCppClass * c =