GKInvalidArgumentException on iOS6

Forums Programming high score, social and ads networks GKInvalidArgumentException on iOS6

This topic contains 7 replies, has 7 voices, and was last updated by  iBrad Apps 1 year, 3 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
Author Posts
Author Posts
September 24, 2012 at 4:37 pm #244393

yeahright
@yeahright

Hi All,

I’m getting this error ever since upgrading to iOS6, in code that worked fine before:

Terminating app due to uncaught exception ‘GKInvalidArgumentException’, reason: ‘A GKScore must contain an initialized value.’

I’m using Ray Wenderlich’s GCHelper, here’s the code in question:

[score reportScoreWithCompletionHandler:^(NSError *error) {

dispatch_async(dispatch_get_main_queue(), ^(void)

{

if (error == NULL) {

NSLog(@"Successfully sent score!");

[scoresToReport removeObject:score];

[self save];

}

else {

NSLog(@"Score failed to send... will try again later. Reason: %@", error.localizedDescription);

}

Thanks for any help!

September 24, 2012 at 5:06 pm #388985

yeahright
@yeahright

Well, as is always the way I’ve fixed the problem, but it’s a hack rather than a real solution. I’ve no idea why it’s just started happening in iOS6.

Anyhow, if anyone else stumbles upon this thread – here’s my hack / solution:

- (void)sendScore:(GKScore *)score {

// Pull the score value and category from the passed in score

int scoreValue = score.value;

NSString*scoreCategory = score.category;

// Create a new temporary score with these values

GKScore *toReport = [[[GKScore alloc]

initWithCategory:scoreCategory] autorelease];

toReport.value = scoreValue;

// Report the temporary score, delete the original on success

[toReport reportScoreWithCompletionHandler:^(NSError *error) {

dispatch_async(dispatch_get_main_queue(), ^(void)

{

if (error == NULL) {

NSLog(@"Successfully sent score!");

[scoresToReport removeObject:score];

[self save];

}

else {

NSLog(@"Score failed to send... will try again later. Reason: %@", error.localizedDescription);

}

});

}];

}

September 25, 2012 at 3:43 am #388986

jbb
@jbb

Exactly the same thing started happening to me today…

Only with iOS6.0 & Xcode4.5, simulator or physical iPhone5.

if I roll back on my other system still under Xcode4.3 and iOS5.1, works perfectly fine, like it’s been doing for over a year.

Glad it’s not just me.

Any idea what has changed? GameCenter has obviously been tweaked quite a bit lately with those added challenges etc…

Might be worth asking Ray himself? His GCHelper might be getting outdated now!

Anyways, I’ve tried your hack. And it seems to work indeed! Nice!!! Thanks for that…

Did you ever get the same crash for the SendAchievements method?

Just the scores?

Cheers,

JBB

September 28, 2012 at 4:32 am #388987

mikeg
Participant
@mikeg

Well, we just got hit with this bug too. A complete surprise! Thanks for the workaround, I’ll give that a go for now. But I’m also curious if there is a similar bug with sending achievements.

This bug seems strange in that you basically have to allocate and initialize a new GKScore that is filled in with the same values from the current GKScore. We’ve only seen this bug when trying to resend a saved score, so I wonder if there is something about reading a saved score that now doesn’t initialize something correctly in the GKScore. Who know…

September 28, 2012 at 11:00 pm #388988

adamk77
Participant
@adamk77

I was getting the same issue. And the workaround seems to fix it.

Also tested if there’s a similar issue with achievements, and there doesn’t seem to be (at least for me).

September 29, 2012 at 5:41 pm #388989

JBacal
@jbacal

Same issue here. Thanks so much for the fix!

–Jay

October 17, 2012 at 2:50 pm #388990

Interactive Computer Solutions Inc.
@ics

Ahh thank you very much yeahright this has been bugging me for several weeks now! Works great!

December 26, 2012 at 4:49 am #388991

iBrad Apps
@ibrad-apps

Thanks, that fix did it for me too! :)

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.