Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct useage ? #97

Closed
acegames opened this issue May 7, 2014 · 10 comments
Closed

Correct useage ? #97

acegames opened this issue May 7, 2014 · 10 comments

Comments

@acegames
Copy link

acegames commented May 7, 2014

Is this the correct useage to verify my own app ?

it is all working correctly but the view this is in does not dealloc while this code is run

My project is ARC but I always log out the dealloc method to see if it is cleaning up ok

If I enter / exit this view with just the code below the memory keeps increasing

//
self.twitter = [STTwitterAPI twitterAPIAppOnlyWithConsumerKey:kTwitterAPI consumerSecret:kTwitterSECRET];
[_twitter verifyCredentialsWithSuccessBlock:^(NSString *bearerToken) {
NSLog(@"Access granted with %@", bearerToken);
} errorBlock:^(NSError *error) {
NSLog(@"-- error %@", error);
}];

@nst
Copy link
Owner

nst commented May 7, 2014

This code seems correct to me.

I can't get why there would be a leak here.

@acegames
Copy link
Author

acegames commented May 7, 2014

Thanks for the speedy reply , it is puzzling me as a new view added with just above in viewDidLoad leaks , and logs the dealloc fine without it ?

It only leaks on verifyCredentials , the self.twitter = [STTwitterAPI twitterAPIAppOnlyWithConsumerKey:kTwitterAPI consumerSecret:kTwitterSECRET]; is fine

Any thoughts to where it could be leaking ?

@acegames
Copy link
Author

acegames commented May 7, 2014

Could you check this method please ?

  • (void)verifyCredentialsWithSuccessBlock:(void(^)(NSString *username))successBlock
    errorBlock:(void(^)(NSError *error))errorBlock;

@nst
Copy link
Owner

nst commented May 7, 2014

In STTwitterAPI.m, could you replace the implementation of verifyCredentialsWithSuccessBlock:errorBlock: with this one and tell me if your dealloc gets called?

- (void)verifyCredentialsWithSuccessBlock:(void(^)(NSString *username))successBlock errorBlock:(void(^)(NSError *error))errorBlock {

    STTwitterAPI * __weak weakSelf = self;

    if([_oauth canVerifyCredentials]) {
        [_oauth verifyCredentialsWithSuccessBlock:^(NSString *username) {
            weakSelf.userName = username;
            successBlock(_userName);
        } errorBlock:^(NSError *error) {
            errorBlock(error);
        }];
    } else {
        [self getAccountVerifyCredentialsWithSuccessBlock:^(NSDictionary *account) {
            weakSelf.userName = [account valueForKey:@"screen_name"];
            successBlock(_userName);
        } errorBlock:^(NSError *error) {
            errorBlock(error);
        }];
    }
}

@acegames
Copy link
Author

acegames commented May 7, 2014

Sorry still the same issue

@nst
Copy link
Owner

nst commented May 7, 2014

Also can you change this?

- (id)init {
    self = [super init];

    STTwitterAPI * __weak weakSelf = self;

    [[NSNotificationCenter defaultCenter] addObserverForName:ACAccountStoreDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
        // account must be considered invalid

        if(weakSelf == nil) return;

        if([weakSelf.oauth isKindOfClass:[STTwitterOS class]]) {
            weakSelf.oauth = nil;
        }
    }];

    return self;
}

@acegames
Copy link
Author

acegames commented May 7, 2014

Sorry no , still no dealloc logging

@nst
Copy link
Owner

nst commented May 7, 2014

OK could you please send me a minimal project demonstrating the issue? and I'll have a look tonight.

nicolas at seriot dot ch

@acegames
Copy link
Author

acegames commented May 7, 2014

Yes I will send it over , thanks for your time !

@acegames
Copy link
Author

acegames commented May 7, 2014

I closed this as the issue was my 'weakSelf' call in the block causing this

@acegames acegames closed this as completed May 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants