Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

buldre

macrumors newbie
Original poster
Jan 25, 2010
28
0
I need to extract the data i have in my NsMutableArray so that they are readable on my mac in plain text. Im now storing accelerometer data in Nsmutablearrays which works fine, but im just wondering about the best way to "get it out from the phone" ?

NB:

I came accross the possibility of using FTP uploads to transfer files. However, how can i transfer the data in my arrays in such a format that i can read it in plaintext when downloaded from the FTP server?
 
I came accross the possibility of using FTP uploads to transfer files. However, how can i transfer the data in my arrays in such a format that i can read it in plaintext when downloaded from the FTP server?
Encode the data into a plain text file to start with and then transfer it.
 
yeah, that sounds reasonable. Im not used to working on the Iphone SDK, or any os x framework for that matter. How would you go about encoding it into a plain text file then? im used to c/c++/C# where everything i write to to is a plain textfile :p Could you hint me in the right direction?
 
let me refrase my question.



ok, so i have an nsmutablearray with nsdecimalnumbers in it. What i want to do, is to build a file locally on the Iphone that is readable in plaintext, and has 1 number on each line. (this means that im going to loop through the NSMutableArray, and for each NSDecimalNumber in it, i want to have one line in the file.

Ok, then after i have made this file, i need to get a hold of it on my mac, i.e. extract it from the iphone. I have found that one can upload to FTP server using objective-c. but i cannot understand how i do this, could someone please help me with some example code? this is very easy in C# for instance, and it is probably just as easy here, just that i dont understand how i do it.

all help is GREATLY appreciated!!
 
ok, so i have an nsmutablearray with nsdecimalnumbers in it. What i want to do, is to build a file locally on the Iphone that is readable in plaintext, and has 1 number on each line. (this means that im going to loop through the NSMutableArray, and for each NSDecimalNumber in it, i want to have one line in the file.
Here's how I would approach this part it: Create a mutable string to hold your plain text. As you loop through each element of the array, convert the number into a string and append that onto the mutable string, along with a line feed character. When the loop is done you should have a string that can be converted to an NSData for file writing.

Concern: what are you going to do with this file once it's on the server? If you plan to parse it, you may want to put the data into some kind of structured format (XML or JSON) in order to make that task easier.

Ok, then after i have made this file, i need to get a hold of it on my mac, i.e. extract it from the iphone. I have found that one can upload to FTP server using objective-c. but i cannot understand how i do this, could someone please help me with some example code? this is very easy in C# for instance, and it is probably just as easy here, just that i dont understand how i do it.
I don't believe it's gonna be that easy. You can find some advice in the CFNetwork Programming Guide, particularly the section on Working with FTP Servers.
 
I just want to upload them to the server, im not going to parse them or anything, i just need them on my computer...

Is there an easier way to get a hold of the file? (get it from the iphone to my mac)
 
hm, that may be an possibiity.. but i read that they removed this capability from the framework?

Is there no way of just connecting my phone to my computer and then just copy it out manually?
 
hm, that may be an possibiity.. but i read that they removed this capability from the framework?
Where did you read that? Because with iPhone SDK 3.0, they actually added a MessageUI framework that makes it possible to send an email without even leaving your application.

Is there no way of just connecting my phone to my computer and then just copy it out manually?
Not without jailbreaking, no.
 
I dont quite remember where I read it. So email seems like the best option?
 
So email seems like the best option?
"Best" is a pretty ambiguous term. If you use email, you'll still need to view the message on your Mac and then download the content to your filesystem. If you use FTP, you can avoid those steps but then need to make sure you have an FTP server on your Mac and will need to code the FTP transfer smarts into your app. And other approaches probably have other advantages...
 
Maybe "best" was the wrong choice of word, however all the examples I can find has to send turn over the control to the mail app inside the Iphone and let the user finish the task, and then return to the original (our) app. I was looking for a way to do transfer the files in the background as you might have understood..

Anyways, i found http://istorageapp.com/ this application which seemingly lets me browse the documents folder of each application? if i can get that working then i can just use that application on the side to transfer my files. Does anyone have some experience with this app?

And i tried the following code, where probex is an NsMutableArray with NsdecimalNumber objects in it. All i wanted to acheive with this functoin was to make the contents of probex into a string and print it to my console. I do not get any warnings or errors, but my application terminates ungracefully and does not print the string. After some debugging it seems that it doesnt even complete the loop.

Code:
-(void) toFile{
	NSString *tmp;
	tmp = [[NSString alloc] initWithString:@""];
	NSMutableString *storagestring;
	storagestring = [[NSMutableString alloc] initWithString:@""];
	
	for(NSDecimalNumber *temp in probex){
		tmp = [temp stringValue];
		[storagestring appendString:tmp];
		[storagestring appendString:@"\n"];
	}

	NSLog(@"string made from probex:\n %@", storagestring);

}
 
It's on your Mac.

Open up the docs window. Type SimpleFTP into the search box. Choose Full-Text search and you'll see it.

Also, there is a page on the developer site that has all the apple sample code where you could find it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.