Note that there are some explanatory texts on larger screens.

plurals
  1. POWeird memory issues, with ARC enabled
    primarykey
    data
    text
    <p>I am having a very, very strange error, probably related to memory management (even though I'm using ARC).</p> <p>I have a my AppDelegate, Foo, and SubFoo (which is a subclass of Foo).</p> <p>Foo.h</p> <pre><code>@protocol FooDelegate &lt;NSObject&gt; - (void)didReceiveDownloadRequest:(NSURLRequest *)downloadRequest; @end @interface Foo : NSObject { __weak id &lt;FooDelegate&gt; delegate; } - (void)performRequest; @property (nonatomic, weak) id &lt;FooDelegate&gt; delegate; @property (nonatomic, retain) NSString *fileIdentifier; </code></pre> <p>Foo.m</p> <pre><code>@implementation Foo @synthesize delegate, fileIdentifier; - (id)init { if ((self = [super init])) { self.delegate = nil; // I tried leaving this line out, same result. NSLog(@"I am %p.", self); } return self; } - (void)performRequest { // Bah. } @end </code></pre> <p>SubFoo.h</p> <pre><code>@interface SubFoo : Foo { WebView *aWebView; } </code></pre> <p>SubFoo.m</p> <pre><code>- (void)performRequest { if (self.fileIdentifier) { aWebView = [[WebView alloc] init]; [aWebView setFrameLoadDelegate:self]; [[aWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"theURL"]]; } } - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame { NSLog(@"Finished loading."); // ... NSLog(@"Class Name: %@", NSStringFromClass([self class])); NSLog(@"Memory Location of delegate: %p", self.delegate); // ... } </code></pre> <p>Sometimes, the class name on webView:didFinishLoadForFrame: returns a completely different class (instead of SubFoo, it returns random classes, like NSSet, NSArray, it even sometimes returns CFXPreferencesSearchListSource), other times it just crashes there with an EXC_BAD_ACCESS, and when it returns a random class on Class Name: it returns that [randomClassName delegate] is an unrecognized selector.</p> <p><strong>EDIT</strong>: When self gets set to another thing, it gets set RIGHT on webView:didFinishLoadForFrame:, and on performRequest it is ALWAYS SubFoo.</p> <p>Any help here would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload