Thursday, July 24, 2014

Reading a content of file (Text, Xml format)


 NSError *errorFileReading;  

 //Read file from mainBundle
 NSString *strFileContent = [NSString stringWithContentsOfFile:[[NSBundle mainBundle]
                pathForResource: @"fileName" ofType: @"txt"] encoding:NSUTF8StringEncoding  
                error:&errorFileReading];
        
 if(errorFileReading) {  //Handle error           
     NSLog(@"errorFileReading");

 } 

 if (strFileContent) {
    //Handle file content over here

 }

No comments:

Post a Comment