Note that there are some explanatory texts on larger screens.

plurals
  1. POposting high score on facebook using graph api
    text
    copied!<p>Edit: 10-9-10<br> I think the app is crashing when the JSON library tries to parse the </p> <pre><code>[NSString stringWithFormat:@"%d weeks",[components week]]; </code></pre> <p>How would i format it so that JSON can parse it?</p> <p>Here's the JSON code line</p> <pre><code>NSString *attachmentStr = [jsonWriter stringWithObject:attachment]; NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: kAppId, @"api_key", @"Share on Facebook", @"user_message_prompt", actionLinksStr, @"action_links", attachmentStr, @"attachment", nil]; </code></pre> <p>Can anyone point me to a tutorial on how to do this? I can easily post the static text in the code block below but i can't integrate an <code>NSString</code> with dynamic data, it doesn't show up on the Fb post attachment section.</p> <pre><code> NSDictionary *attachment = [NSDictionary dictionaryWithObjectsAndKeys: @"Testing", @"name", @"testing2", @"caption", [NSString stringWithFormat:@"%d weeks",[components week]], @"description"//Xcode says components undeclared //highscore, @"description", //here's the problem, highscore is the NSString variable. @"http://testing.com/", @"href", nil]; </code></pre> <p>Update: the problem is the string i'm using is from a time interval of the difference of 2 weeks and the out put is <code>[components week]</code> and then xcode tells me components is an undeclared variable</p> <pre><code>[NSString stringWithFormat:@"%d weeks",[components week]] </code></pre> <p>here's the whole date code block that i get the string above from:</p> <pre><code>NSString *dateStr = @"20100716"; NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"yyyyMMdd"]; NSDate *startDate = [dateFormat dateFromString:dateStr]; NSDate *endDate = [NSDate date]; NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSUInteger unitFlags = NSWeekCalendarUnit | NSDayCalendarUnit; NSDateComponents *components = [gregorian components:unitFlags fromDate:startDate toDate:endDate options:0]; NSInteger weeks = [components week]; NSInteger days = [components day]; </code></pre>
 

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