Somehow I got this error in XCode 4.0.2, not sure what is wrong.
File: HomeViewController.h
#import <UIKit/UIKit.h>
#interface HomeViewController : UIViewController <UITabBarDelegate>
{
UIButton *Button1, *Button2, *Button3;
}
#property (nonatomic, retain) IBOutlet UIButton *Button1;
#property (nonatomic, retain) IBOutlet UIButton *Button2;
#property (nonatomic, retain) IBOutlet UIButton *Button3;
.... other member functions...
....
#end
File: HomeViewController.m
......
#import "RemoteServiceManager.h"
#interface HomeViewController()
{ //This is where the error happens: Expected Identifier or "(" before "{" token
RemoteServiceManager* serviceManager;
}
#end
#implementation HomeViewController
#synthesize Button1, Button2, Button3;
.... other member functions
....
#end
Looks like it does not recognize RemoteServiceManager. Wherever I used the serviceManager, it will say HomeViewController has no member named serviceManager.
Is it possible that is caused by XCode version? I am using XCode 4.0.2 on Mac OS X 10.6.7.
Thanks.
you cant add instance variables to private categories.
put properties in there instead, and synthesize them to obtain a variable as well as an internal getter/setter
#interface HomeViewController
#property (nonatomic, strong) NSString *privateProperty;
#end
#implementation HomeViewController
#synthesize privateProperty = _privateProperty;
#end
or you can add the instance variable to the class itself.
#implementation HomeViewController
NSString *privateVariable;
#end
Bear in mind also. that if you create a category in another file, any variables you declare in the body of that category will be static across all instances. definitely something to keep an eye out for.
To recap. you can create a variable in the interface of the main category. or in the implementation of the main category.
and the private category is for you to add prototypes to your class that will let the rest of the file know they "will be/are" available.
the old xcode cant do this, no. it does know class extensions yet because it ships with an older version of the LLVM compiler
You probably found your answer, but I post the answer here for somebody who encounters the same problem:
as Daij said, the problem is due to the version of compiler, so to fix this you need to change the compiler setting:
Build Setting > Build Options > Compiler for C/C++/ObjectiveC
Change value from "LLVM GCC 4.2" to "Apple LLVM compiler 4.2"
Hope it helps.
Related
#property (unsafe_unretained,nonatomic) id<SceneDelegate> delegate;
it works fine on xcode 5, but it gives me this error on xcode 6.1
Error: Property type 'id<SceneDelegate>' is incompatible with type 'id<SKSceneDelegate>' inherited from 'SKScene'
what's that mean?
Addition:
beginning of scene.h
#protocol SceneDelegate <NSObject>
- (void) eventStart;
#end
#interface Scene : SKScene<SKPhysicsContactDelegate>
#property (unsafe_unretained,nonatomic) id<SceneDelegate> delegate;
viewController.h
#import "Scene.h"
#import <AVFoundation/AVFoundation.h>
#interface ViewController : UIViewController<SceneDelegate, AVAudioPlayerDelegate>
viewController.m
scene.delegate = self;
That's all the lines contain SceneDelegate.
It means SKScene already has a property of the same name: delegate
You are trying to redeclare that property but with a different protocol: SceneDelegate instead of SKSceneDelegate.
So either you wanted to use the delegate property, in that case you needn't declare that property, just assign your SKSceneDelegate object to the delegate property. For example:
self.delegate = mySceneDelegateObject;
Otherwise use a different name instead of delegate if SceneDelegate is an actual protocol you created (and consider renaming the protocol because it's easily confused with SKSceneDelegate).
I know this is a common problem, however I couldn't find the solution to mine.
I'm following cs193p Standford course, following letter by letter the code at the lecture slides, and Xcode 4.6 still produces an error witch didn't occur to Xcode 4.4.something...
PlayingCardDeck.h:
#import "Deck.h"
#interface PlayingCardDeck : NSObject
#end
PlayingCardDeck.m:
#import "PlayingCardDeck.h"
#import "PlayingCard.h"
#implementation PlayingCardDeck
...
[self addCard:card atTop:YES]; //problem occurs here
...
#end
deck.h:
#import <Foundation/Foundation.h>
#import "Card.h"
#interface Deck : NSObject
- (void)addCard:(Card *)card atTop:(BOOL)atTop;
...
#end
deck.m:
#import "Deck.h"
#interface Deck()
#property (strong, nonatomic) NSMutableArray *cards;
#end
#implementation Deck
...
- (void)addCard:(Card *)card atTop:(BOOL)atTop
{
if (atTop)
[self.cards insertObject:card atIndex:0];
else
[self.cards addObject:card];
}
...
#end
By logic, addCard:atTop: should be a (+) method? In the lecture it was being a (-) just fine. In addition, after trying to change it to a (+) method, it creates 6 additional problems witch demand using entirely different syntax for each time I'm going for "self".
In short, I'm really confused by now...
Problem is addCard: atTop is a method of Deck, not a method ofPlayingCardDeck.
Maybe PlayingCardDeck should inherit from Deck? Or there is an iVar of PlayingCardDeck which is a deck?
I'm trying to create a custom class for this online tut:
http://mobile.tutsplus.com/tutorials/iphone/design-build-a-small-business-app-aqgridview/
and about a quarter of the way down the page it says:
"Select the MainStoryboard_iPhone file and change the Class of the SecondViewController nib to GridViewController."
However, for the life of me, GridViewController won't come up in the custom class options!
I've followed the instructions:
"Cocoa Touch->Objective -C Class->NSObject template. Call it GridViewController. "
And put into my .h file:
#import <UIKit/UIKit.h>
#import "AQGridView.h"
#interface GridViewController : UIViewController <AQGridViewDelegate, AQGridViewDataSource>
#property (nonatomic, retain) IBOutlet AQGridView * gridView;
#property (nonatomic, retain) NSArray * services;
#end
Shouldn't it show up as a class?
Have you made sure that you are setting the custom class of the view controller object in the nib?
You could try cleaning and building your project again to make sure everything is indexed properly, or you could try manually entering the class name in the custom class field and then compiling to see if any helpful errors are thrown.
I receive this error
Property implementation must have its declaration in interface "AppDelegate"
When I declare
#implementation AppDelegate
#synthesize window, viewController;
#synthesize token;
I'm using Xcode 4.4.
This means that you need to go to your AppDelegate.h file, and add a declaration for token. Let's say it's NSString*; then you should add the following line to your .h file:
#property (nonatomic, readwrite) NSString *token;
Substitute NSString* for the correct type of your token property. More information about properties can be found here.
It looks like you didn't set widow, viewController or token as properties in your .h file.
Did you type #property (nonatomic, strong) NSString *token;
I'm trying to make a shared iAd bannerview for the view controllers throughout my ios application. I've been attempting to make a singleton class in my app delegate in order to do this but I keep getting an error saying, "interface type 'iAdClass' cannot be returned by value." I have no clue how to fix this, my setup for a singleton may be incorrect also, so any help with that would be appreciated also.
#import <UIKit/UIKit.h>
#class ViewController;
#class iAdClass;
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#property (strong, nonatomic) ViewController *viewController;
#property (assign) iAdClass*iADObject;
+ (AppDelegate*) sharedApplication;
+ (iAdClass)sharedAd;
#end
hi i did this it works but cant find how to remove adds if no internet connection
How to create a global reference for iAd and implement in multiple Viewcontrollers