4
votes

I was following the steps here: http://matt.might.net/articles/how-to-native-iphone-ipad-apps-in-javascript/

Here are the bare bones steps to turning a web app into a native app:

  1. Open XCode.
  2. Create a new "View-based Application" iPhone project.
  3. Move the files for your web app into the Resources folder in XCode, but strip out the cache manifest. (You don't want the manifest screwing things up, since everything is now local.)
  4. Create a new instance variable, webView, inside the @interface ViewController header file: IBOutlet UIWebView* webView ; // IBOutlet means it's visible to Interface Builder.
  5. and create a property: @property (nonatomic, retain) UIWebView *webView;

Here is what I have thus far (ViewController.h):

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

    IBOutlet UIWebView* webView;

@property (nonatomic, retain) UIWebView *webView;
@end

However on step 4 I am getting two errors in my ViewController header file:

enter image description here

"cannot declare variable inside @interface or @protocol"

and

"iboutlet attribute can only be applied to instance variables or properties"

So what am I doing wrong, or is that website tutorial wrong?

Note: I downloaded the sample project he had for iPhone and it worked, but I am following the tutorial so I can make an iPad version.

I am in XCode 4 and the error shows whether I do iOS 5 or iOS 4.3 doesn't seem to make a difference.

2

2 Answers

6
votes

You're missing a couple of curly braces there:

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController {
    UIWebView *webView;
}

@property (nonatomic, retain) IBOutlet UIWebView *webView;

@end
2
votes

I think you forgot the brackets; try to change your code to

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController {

    IBOutlet UIWebView* webView;
}

@property (nonatomic, retain) UIWebView *webView;
@end