iphone graph api not working to post image in facebook
<p><strong>using this method to post the image</strong></p>

<pre><code>- (void)postInAppFacebook {

    btnForLogout.hidden=NO;
    NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:3];

    NSData *imageData = UIImageJPEGRepresentation(imgPicture.image, 4.0);


    UIImage *picture = [[UIImage alloc]initWithData:imageData];


    FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:picture];


    [variables setObject:graph_file forKey:@"file"];

    [variables setObject:[NSString stringWithFormat:@"%@", txtComment.text] forKey:@"message"];




    **[fbGraph doGraphPost:@"me/photos" withPostVars:variables];**




    NSLog(@"Now log into Facebook and look at your profile &amp; photo albums...");
    UIAlertView *alertForImageHasPost=[[UIAlertView alloc]initWithTitle:@"MAP IMAGE POST" message:@"SELECTED IMAGE POSTED" delegate:self cancelButtonTitle:@"CANCEL" otherButtonTitles:@"OK",nil];
    [alertForImageHasPost show];
    [alertForImageHasPost release];

    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];  
}
</code></pre>

<p><strong>problem in this method</strong>
second time its crash but working well in simulator</p>

<pre><code>- (FbGraphResponse *)doGraphPost:(NSString *)action withPostVars:(NSDictionary *)post_vars {
    NSLog(@"action is %@",action);
    FbGraphResponse *return_value = [[FbGraphResponse alloc] init];

    NSString *urlString = [NSString stringWithFormat:@"https://graph.facebook.com/%@", action];

    NSURL *url = [NSURL URLWithString:urlString];
    NSString *boundary = @"----1010101010";
    NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request setHTTPMethod:@"POST"];
    [request addValue:contentType forHTTPHeaderField: @"Content-Type"];

    NSMutableData *body = [NSMutableData data];
    [body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];

    NSEnumerator *enumerator = [post_vars keyEnumerator];
    NSString *key;
    NSString *value;
    NSString *content_disposition;

    //loop through all our parameters 
    while ((key = (NSString *)[enumerator nextObject])) {

        //if it's a picture (file)...we have to append the binary data
        if ([key isEqualToString:@"file"]) {

            /*
             * the FbGraphFile object is smart enough to append it's data to 
             * the request automagically, regardless of the type of file being
             * attached
             */
            FbGraphFile *upload_file = (FbGraphFile *)[post_vars objectForKey:key];
            [upload_file appendDataToBody:body];

        //key/value nsstring/nsstring
        } else {
            value = (NSString *)[post_vars objectForKey:key];

            content_disposition = [NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", key];
            [body appendData:[content_disposition dataUsingEncoding:NSUTF8StringEncoding]];
            [body appendData:[value dataUsingEncoding:NSUTF8StringEncoding]];

        }//end else

        [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];

    }//end while

    //add our access token
    [body appendData:[@"Content-Disposition: form-data; name=\"access_token\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[accessToken dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];

    //button up the request body
    [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];

    [request setHTTPBody:body];
    [request addValue:[NSString stringWithFormat:@"%d", body.length] forHTTPHeaderField: @"Content-Length"];

    //quite a few lines of code to simply do the business of the HTTP connection....
    NSURLResponse *response;
    NSData *data_reply;
    NSError *err;
**//crash after this  line**
    ***

&gt; data_reply = [NSURLConnection sendSynchronousRequest:request
&gt; returningResponse:&amp;response error:&amp;err];

***
    return_value.htmlResponse = (NSString *)[[NSString alloc] initWithData:data_reply encoding:NSUTF8StringEncoding];

    if (err != nil) {
        return_value.error = err;
    }

    /*
     * return the json array.  we could parse it, but that would incur overhead 
     * some users might not want (not to mention dependencies), besides someone 
     * may want raw strings back, keep it simple.
     *
     * See:  http://code.google.com/p/json-framework for an easy json parser
     */

    return return_value;
}
</code></pre>
