Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Image from REST with JSON

how can i save a array of binary from REST webservice as Image file using JSON?
Post edited by illDev on

Replies

  • QuantumDojaQuantumDoja Posts: 623Registered Users
    I would base64 the binary.
    www.itheme.com
    deal.gameweaver.com
    guessem.gameweaver.com
  • illDevillDev Posts: 2New Users
    QuantumDoja;421440 said:
    I would base64 the binary.

    i made(but it doesn't work):


    - (NSString *)localPath:(NSString *)file
    {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex
    :0];
    NSString * result;
    result = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", file]];
    NSLog(@"%@", result);
    return result;
    }

    - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
    [responseData release];

    NSDictionary *results = [responseString JSONValue];

    NSMutableArray *arrayBytes = [[results valueForKey:@"data"]objectAtIndex:0];

    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:arrayBytes];

    NSString *nameOfImage = @"test";
    [data writeToFile:[self localPath:nameOfImage] atomically:YES];

    }
Sign In or Register to comment.