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

NSInvalidArgumentException with getSelfLikesWithSuccess call #23

Closed
ddaddy opened this issue Mar 18, 2014 · 6 comments
Closed

NSInvalidArgumentException with getSelfLikesWithSuccess call #23

ddaddy opened this issue Mar 18, 2014 · 6 comments

Comments

@ddaddy
Copy link

ddaddy commented Mar 18, 2014

When I call getSelfLikesWithSuccess I get an exception crash

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithString:]: nil argument

on line 19 of InstagramPaginationInfo.m

info[kNextMaxId] is in fact nil.

@ddaddy
Copy link
Author

ddaddy commented Mar 18, 2014

Ok, i've found the problem.
This define #define kNextMaxId @"next_max_id" needs to be changed to this #define kNextMaxId @"next_max_like_id"

I'm not sure if that will break anything else though.

@ddaddy ddaddy mentioned this issue Mar 18, 2014
@ddaddy
Copy link
Author

ddaddy commented Mar 18, 2014

I've found another similar too. Where pagination is empty but not nil.
Changing if (self && IKNotNull(info)) { to if (self && IKNotNull(info) && [info count] > 0) { seems to fix it.

@ddaddy
Copy link
Author

ddaddy commented Mar 18, 2014

This does break other functions. So try this instead:

- (id)initWithInfo:(NSDictionary *)info
{
    self = [super init];
    if (self && IKNotNull(info) && [info count] > 0) {
        NSLog(@"%@", info);
        _nextURL = [[NSURL alloc] initWithString:info[kNextURL]];
        if (IKNotNull(info[kNextMaxId]))
            _nextMaxId = [[NSString alloc] initWithString:info[kNextMaxId]];
        else if (IKNotNull(info[kNextMaxLikeId]))
            _nextMaxId = [[NSString alloc] initWithString:info[kNextMaxLikeId]];
    }
    return self;
}

and you'l need to add a new define
#define kNextMaxLikeId @"next_max_like_id"

@pingusNikalex
Copy link

Here is my Fix

if (self && IKNotNull(info) && IKNotNull(info[kNextURL]) && IKNotNull(info[kNextMaxId])) {
    _nextURL = [[NSURL alloc] initWithString:info[kNextURL]];
    _nextMaxId = [[NSString alloc] initWithString:info[kNextMaxId]];
}

WBR, Alexandr Chernyy
Team Lead, Nikolaev
Tatem Games Nikolaev
Skype: pingus_kisya
Phone: +38 (093) 561 56 30
E-mail: alexandr.chernyy@tatemgames.com
www.tatemgames.com

On Mar 18, 2014, at 5:29 PM, ddaddy notifications@github.com wrote:

This does break other functions. So try this instead:

  • (id)initWithInfo:(NSDictionary *)info
    {
    self = [super init];
    if (self && IKNotNull(info) && [info count] > 0) {
    NSLog(@"%@", info);
    _nextURL = [[NSURL alloc] initWithString:info[kNextURL]];
    if (IKNotNull(info[kNextMaxId]))
    _nextMaxId = [[NSString alloc] initWithString:info[kNextMaxId]];
    else if (IKNotNull(info[kNextMaxLikeId]))
    _nextMaxId = [[NSString alloc] initWithString:info[kNextMaxLikeId]];
    }
    return self;
    }
    and you'l need to add a new define
    #define kNextMaxLikeId @"next_max_like_id"


Reply to this email directly or view it on GitHub.

@ddaddy
Copy link
Author

ddaddy commented Mar 19, 2014

I don't think that will fix it. There is a different json key for nextmax for likes than the other nextmax's.
next_max_like_id next_max_id

@shyambhat
Copy link
Owner

I'm doing the error checking now, and have also added the additional macro.
Thanks a bunch for the fixes, guys.
You could just fork the project, going ahead and send me pull requests with your fixes so I can review and merge it right from my inbox. This will make things much quicker and also make you contributors of the repo.

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

3 participants