Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Reading file in Obj-C

Reading file in Obj-C
Thread Tools
Fresh-Faced Recruit
Join Date: Sep 2001
Status: Offline
Reply With Quote
Jun 21, 2004, 10:34 PM
 
I'm trying to figure out how to read a file that is just a bunch of integers into some sort of array (integer) so I can use it to draw a 2D line graph of the data when I press a button. I've figured out how to draw the graph, but can't get the data to be read. I'm rather new at Obj-C and have been searching for this answer for a while, but to no avail. Any help would be greatly appreciated. Thanks.
Powerbook G4 400 / 10.3.7
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Jun 21, 2004, 11:31 PM
 
Various classes have file-reading methods, including NSString and NSData. You can also use NSFileHandle or the normal C file-reading APIs.

How you parse the string is up to you. The most basic Cocoa way would be to read the file into an NSString and use NSScanner to find your tokens.
(Last edited by Chuckit; Jun 21, 2004 at 11:45 PM. )
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:36 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2