Sunday, May 1, 2011

iPhone Data

I'm trying to extract about 72000 SInt32s from the iPhone, but not sure what the best approach is. Using printf or NSLog to the console basically crashes my program and my computer. I tried redirecting stderr to a file, but I run into the same problem. Was wondering what the best way is to extract this data so I can later use it on my desktop for plotting.

From stackoverflow
  • Depends on a lot of things. For example, what format are those numbers in? You could do a HTTP POST to a netcat sitting on the desktop machine:

    NSURL *url = [NSURL URLWithString:@"http://desktop:3000/"];
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
    [request setHTTPMethod:@"POST"];
    [request setHTTPBody:…];
    NSURLConnection *connection = [[NSURLConnection alloc]
        initWithRequest:request delegate:self];
    NSAssert(connection, @"Failed to create connection.");
    

    And on the desktop:

    $ nc -l 3000
    

    You’ll get something like this:

    POST / HTTP/1.1
    User-Agent: YourApp1.0 CFNetwork/422.15.2 Darwin/9.6.0 (i386) (MacBook4%2C1)
    Accept-Language: en-us
    Accept-Encoding: gzip, deflate
    Content-Type: application/x-www-form-urlencoded
    Content-Length: xxx
    Connection: keep-alive
    Host: 127.0.0.1:3000
    
    //data
    
    Sam : Can you expound on this a little bit? I have never used this before...
    zoul : What exactly do You need help with? The “server” part (the code on the desktop), or the “client” part, the code on the device?

0 comments:

Post a Comment