xcode - Parsing a .csv file from a server with Objective-C -


I have searched for a long time and still no one has found, so I thought I would ask questions myself.

In my iPad app, I have the ability to parse the CCV file to populate the table. I'm using to parse CSV files, however, I've only been able to parse local files. I'm trying to use a file from a server, but I'm not getting anywhere.

- (zero) alertview: (UIAlertView *) AlertViews clicked Button atindex: (NSITer) button index {if (button index == 1} {// UITdefilled * Answer = [Warning View TextFilmIntex: Button Index]; NSString * fileName = input.text; NSLog (@ "filename% @", filename); CSVParser * parser = [CSVParser new]; If ([filename length]! = 0) {NSString * pathAsString = [[NSBundle main bundle] Pathfoser resource: Type the name of the file: @ "CSV"]; NSLog (@ "% @", Path Asstring); If (pathAsString! = Zero) {[Parcel OpenFile: PathSTestring]; NSMutableArray * csvContent = [parser parsefile]; NSLog (@ "% @", csvContent); [Parser closfile]; NSMutableArray * Title = [csvContent objectAtIndex: 0]; [Remove CSV contentAbjectIndexX: 0]; NSLog (@ "% @", title); AppDelegate * AP = [AppDelegate sharedAppDelegate]; NSManagedObjectContext * context = [App Managed Contact]; NSString * currentHeader = [object header: 0]; NSString * currentValueInfo = [Object header: 1]; NSManagedObject * newObject = [NSEntityDescription insertNewObjectForEntityForName: @ Managed object contexts in "field": context]; [NewObject setValue: @ "MIS" for: @ "Header"]; [NewObject setValue: currentHeader forKey: @ "fieldName"]; (NSArray * currently csvContent) {NSManagedObject * newField = [NSEntityDescription insertNewObjectForEntityForName: @ Managed object contexts in "field": context]; [NewField setValue: currentHeader forKey: @ "Header"]; [NewField setValue: currentValueInfo forKey: @ "valueInfo"]; NSLog (@ "% @", [current object endx: 0]); [NewField setValue: [current object at index: 0] for: @ "field name"]; [NewField setValue: [NSNR Number Repeat: [[Current ObjectOutIndexX: 1] Double Value]] for: @ "Value"]; } NSError * error; If (! [Avoid context: & amp; error]) {NSLOG (@ "could not save:% @", [error localized description]); } [Self Storey]; [Self.tableViewReloadData]; }}} Input.text = Nil; }

Finish strange start and brace indentation. Anyway, in order to take input from a user, my code is and use a file locally that I'm sure that people have already realized. Now I want to know. How to get a file path in my server

In addition to this, if you see anything wrong with writing style and other bad habits, please tell me because I am new to iOS

Thank you very much! If you can not understand my question please clarify as I explain myself many times! :)

As I think you are the server's Trying to get data from the Csv file and want to show data in the table view list.

That's why I recommend that you get into NSDTa Try to get the CCV file data and then work on it.

  NSData * responseData = [NSData data content content URL: [NSL URL URL string: @ "server URL"]]; NSString * csvResponseString = [[[NSString alloc] initWithData: responseData encoding: NSUTF8StringEncoding] autorelease]; NSLog (@ "responseString --->% @", csvResponseString);  

Now try using nsstring's method ( componentsSeparatedByString ) with coma (')

  arrSepatedData = [ [ResponseString componentsSeparatedByString: @ ""];  

Now populate this code to UITableView data.


Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -