Leave a Comment:
1 comment

Doesn’t work. Incomplete implementation of class error. Can you a provide working code ?
ReplyWe crate here a files in the application’s Home directory. To make things interesting, we load a web page from the Internet using the http protocol and store that html file in tmp. After that, we use a web view to load the html from the tmp directory and present it to user. We will see, these tasks can be easily achieved using the rich APIs available.
Step 1: Create a Window base application using the template . Give the name FileCreate.
Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.
Step 3: Highlight the classes folder in Groups & Files. Select File -> New File from the menu. Select the UIViewController subclass from the CocoaTouch Classes and click next, give the name of the file FileCreateViewController.m and ensure the Also Create “FileCreateViewController.h”.
Step 4: The declaration of the application delegate class used in the file creation and local file view. So make the following changes in the FileCreateAppDelegate.h file.
1 2 3 4 5 6 7 8 9 |
#import <uikit/UIKit.h> @class FileCreateViewController; @interface FileCreateAppDelegate : NSObject { UIWindow *window; FileCreateViewController *mainctrl; } @property (nonatomic, retain) IBOutlet UIWindow *window; |
Step 5: The implementation of the application delegate. The delegate simply uses the FileCreateViewController as a subview of the main window.
1 2 3 4 5 6 |
- (void)applicationDidFinishLaunching:(UIApplication *)application { window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; mainctrl = [[FileCreateViewController alloc] initWithNibName:nil bundle:nil]; [window addSubview:mainctrl.view]; [window makeKeyAndVisible]; } |
Step 6: In the ViewController header file we create UIWebView instance which will be used to visualize the contents of the local file in tmp. We declares two methods for the creation and visualization of the html file in tmp.
1 2 3 4 5 6 |
@interface FileCreateViewController : UIViewController { UIWebView *webView; } -(void) createAFileInTMP; -(void) loadWebViewWithFileInTMP; |
Step 7: In the FileCreateViewController.m file, the viewDidLoad method is invoked once the view has been loaded. It creates the file by invoking the createAFileInTMP method and after that it loads the web view with the downladed file by invoking the loadWebViewWithFileInTMP method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
#import <foundation/Foundation.h> #import <uikit/UIKit.h> #import "FileCreateViewController.h" @implementation FileCreateViewController - (void)loadView { CGRect rectFrame = [UIScreen mainScreen].applicationFrame; webView = [[UIWebView alloc] initWithFrame:rectFrame]; webView.scalesPageToFit = YES; self.view = webView; } - (void)viewDidLoad { [self createAFileInTMP]; [self loadWebViewWithFileInTMP]; } -(void) loadWebViewWithFileInTMP { NSFileManager *fileManager =[NSFileManager defaultManager]; NSData *data; NSString *fileName = [NSHomeDirectory() stringByAppendingPathComponent:@"tmp/file.html"]; data = [fileManager contentsAtPath:fileName]; [webView loadData:data MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL :[NSURL URLWithString:@"http://www.rss-specifications.com"]]; } -(void) createAFileInTMP { NSFileManager *fileManager =[NSFileManager defaultManager]; NSString *fileName = [NSHomeDirectory() stringByAppendingPathComponent:@"tmp/file.html"]; NSURL *theURL = [[NSURL alloc] initWithScheme:@"http" host:@"www.rss-specifications.com" path:@"/display-rss.htm"]; NSData *data = [[NSData alloc] initWithContentsOfURL:theURL]; BOOL filecreationSuccess = [fileManager createFileAtPath:fileName contents:data attributes:nil]; if(filecreationSuccess == NO){ NSLog(@"Failed to create the html file"); } [theURL release]; [data release]; } - (void)dealloc { [webView release]; [super dealloc]; } |
Step 8: Now compile your application and run onto the simulator.
The Best 15 Mobile Game Development Platforms & Tools in 2018
The Top Web Development Frameworks in 2018
13 programming languages defining the future of coding
The Top 10 Programming Languages To Learn In 2018
The Languages and Frameworks You Should Learn in 2017
Extracting Colors In Android 5.0 – “The Palette API”
The Android Studio – An Introduction With The HelloWorld App
Creating Grouped Table Views In Swift
Doesn’t work. Incomplete implementation of class error. Can you a provide working code ?
Reply