My project works fine on simulator but wouldn't build on real device after adding:
#synthesize extraView=_extraView;
It seems that this line somehow hides file header. Tried "Clean" - no change.
I've used #property and #synthesize many times before and haven't seen anything like this.
I'm planning to rewrite extraView handling but I'm asking just out of curiosity if someone has experienced similar error.
Platform:
XCode 4.0.1
4.2.1 Ipad
File header:
//
// MediaBook.h
// Dolphin
//
// Created by Handymood on 11-5-22.
// Copyright 2011 __Hanydmood__. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "SinglePage.h"
#import "LayerInfo.h"
#import "MediaBookXMLParser.h"
#import "GlobalSet.h"
#import "UIComponentBase.h"
#import "IndexPageInfo.h"
#import "IndexPage.h"
#import "TopBar.h"
#import "BottomBar.h"
#import "DolphinUIWebLayer.h"
#import "MediaBookBase.h"
#import "ColorUtil.h"
#import "DolphinUICategory.h"
#import "UICategoryUnit.h"
#import "ImageInfoBox.h"
#import "Gallery.h"
#import "Calendar.h"
#class SinglePage;
#class LayerInfo;
#class MediaBookXMLParser;
#class GlobalSet;
#class UIComponentBase;
#class IndexPageInfo;
#class IndexPage;
#class TopBar;
#class BottomBar;
#class DolphinUIWebLayer;
#class MediaBookBase;
#class ColorUtil;
#class DolphinUICategory;
#class UICategoryUnit;
#interface MediaBook : MediaBookBase <UIScrollViewDelegate>
{
UIImageLayer *backGroundImage;
UIView *bgView;
BottomBar *bottomBar;
DolphinUIWebLayer *webLayer;
DolphinUICategory *categoryLayer;
UIActivityIndicatorView *activityIndicator;
UIInterfaceOrientation preOrientation;
NSTimer *objQueMagTimer;
float previous_scroll_pos;
BOOL bar_status_hidden;
float top_bar_ori_y;
float bottom_bar_ori_y;
BOOL scroll_block_signal;
int screen_direction;//0:vertical 1:horizontal
BOOL webLayerOn;
BOOL categoryOn;
BOOL changingExtraView;
}
#property UIInterfaceOrientation preOrientation;
#property (nonatomic, retain) UIView *extraView;
-(void) initWithGlobalSet:(GlobalSet *) inGlobalSet;
-(void) initBook:(NSString *)configXmlAdd curOrientation:(UIInterfaceOrientation)interfaceOrientation;
-(void) initBookContent;
-(void) notificationSelector:(NSNotification *) notification;
-(void) statusBarAnimationTrigger;
-(void) layoutAdjustWithOrientation:(UIInterfaceOrientation)interfaceOrientation
orientaionType:(NSString *) inOrientationType;
-(void) closeCategoryLayer;
-(void) reset;
-(void) showExtraView:(NSString *)name;
-(void) hideExtraView;
#end
Screenshot of build errors:
I've used #property and #synthesize many times before and haven't seen any similar.
Adding following to interface declaration solved the problem:
UIView *_extraView;
Thanks to mja for the tip.
Related
Ok, it may be a dumb mistake. But I can't figure out what xcode wants from me.
So here is the header file
#import <Foundation/Foundation.h>
#import "TableViewController.h"
#end
#interface Settings : NSObject
- (id)init: (TableViewController*) TableControll;
#end
If there is no #end before interface it says expected identifier or (, and suggests adding #end there. If there is an #end it says end must appear in objective-c contex.
Ideas?
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMessageComposeViewController.h>
#interface TableViewController : UIViewController<UITableViewDataSource,UITableViewDelegate,MFMessageComposeViewControllerDelegate>
{
ControllerType controllerType;
}
#property (retain, nonatomic) IBOutlet UITableView *tableView;
#property (retain, nonatomic) NSArray *dataArray;
#property (retain, nonatomic) NSArray *imageArray;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil andType:(ControllerType)type;
#end
You have a #end before the #interface declaration in your Settings.h file.
It should read:
#import <Foundation/Foundation.h>
#import "TableViewController.h"
#interface Settings : NSObject
- (id)init: (TableViewController*) TableControll;
#end
Also, you haven't included the #import directive for ControllerType in your TableViewController.h which may be why you're getting obscure errors in your Settings.h file.
I have custom UIView class GestureView. I have a forward declaration for this class and it's delegate below. I have imported GestureView.h in .m file. This works fine but iOS gives warning message saying "Cannot find protocol definition for GestureViewDelegate". If I remove forward declaration it gives same warning message as error. I don't want to import GestureView.h from ContainerViewController.h as I usually imports stuffs in .m file. Could someone please explain what's wrong in following class structure?
ContainerViewController.h
#import <UIKit/UIKit.h>
#class DividerView;
#class GestureView;
#protocol GestureViewDelegate;
#interface ContainerViewController : UIViewController<GestureViewDelegate>
#property (strong, nonatomic) IBOutlet GestureView *topContentView;
#end
GestureView.h
#import <UIKit/UIKit.h>
#protocol GestureViewDelegate;
#interface GestureView : UIView
- (void)initialiseGestures:(id)delegate;
#end
#protocol GestureViewDelegate <NSObject>
#required
- (void)GestureView:(GestureView*)view handleSignleTap:(UITapGestureRecognizer*)recognizer;
#end
I like that you're trying to avoid imports in header files: very good practice. However, to fix your bug you can just make your code even better! In my opinion it's not really necessary that your ContainerViewController class outwardly declares that it supports GestureViewDelegate protocol, so you should move this into your implementation file. Like so:
GestureView.h
#import <UIKit/UIKit.h>
#protocol GestureViewDelegate;
#interface GestureView : UIView
- (void)initialiseGestures:(id <GestureViewDelegate>)delegate;
#end
#protocol GestureViewDelegate <NSObject>
#required
- (void)gestureView:(GestureView *)view handleSingleTap:(UITapGestureRecognizer *)recognizer;
#end
ContainerViewController.h
#import <UIKit/UIKit.h>
#class GestureView;
#interface CollectionViewController : UIViewController
// this property is declared as readonly because external classes don't need to modify the value (I guessed seen as it was an IBOutlet)
#property (strong, nonatomic, readonly) GestureView *topContentView;
#end
ContainerViewController.m
#import "ContainerViewController.h"
#import "GestureView.h"
// this private interface declares that GestureViewDelegate is supported
#interface CollectionViewController () <GestureViewDelegate>
// the view is redeclared in the implementation file as readwrite and IBOutlet
#property (strong, nonatomic) IBOutlet GestureView *topContentView;
#end
#implementation ContainerViewController
// your implementation code goes here
#end
Try this way, and please reply if it works or not.
GestureView.h
#import <UIKit/UIKit.h>
#protocol GestureViewDelegate <NSObject>
#required
- (void)GestureView:(GestureView*)view handleSignleTap:(UITapGestureRecognizer*)recognizer;
#end
#interface GestureView : UIView
- (void)initialiseGestures:(id)delegate;
#end
ContainerView.h
#import <UIKit/UIKit.h>
#class DividerView;
#class GestureView;
/*#protocol GestureViewDelegate;*/ //NO NEED TO WRITE THIS
#interface ContainerViewController : UIViewController<GestureViewDelegate>
#property (strong, nonatomic) IBOutlet GestureView *topContentView;
#end
I've created a file with sql methods and now this file is really large. I'd like to split it for best practice and implementation simplicity. So, categories.
I've created in xCode new objective-c categories file -> DBAccess+Generals.h (.m).
.h:
#import "DBAccess.h"
#interface DBAccess (Generals)
-(void)newMeth;
#end
.m
#import "DBAccess+Generals.h"
#import "DBAccess.h"
#implementation DBAccess (Generals)
-(void)newMeth
{
NSLog(#"New Meth");
}
#end
In DBAccess.h
#import <Foundation/Foundation.h>
#import <sqlite3.h>
#import "DBAccess+Generals.h"
#interface DBAccess : NSObject
{
NSString *databaseName;
}
#property(nonatomic,strong)NSString *databaseName;
DBAccess.m
#import "DBAccess.h"
#import "DBAccess+Generals.h"
#implementation DBAccess
#synthesize databaseName;
sqlite3* database=nil;
-(id)init
{
if ((self=[super init]))
{
//[self initializeDataBase];
databaseName=#"world_coins.db";
//firstVerDB=#"ac_ch_ver.1.0.db";
}
return self;
}
//Tones of methods
#end
Looks like the code is OK. Getting error "interface implementation not found for DBAccess". I've googled and stackoverflowed around, but the issues described, are not my case.
any help? Thank you in advance.
The problem is the cyclic import
#import "DBAccess+Generals.h" in DBAccess.h
#import "DBAccess.h" in DBAccess+Generals.h
If you remove the first one, the code compiles.
I'm getting errors for the appdelegate.h: "expected identifier or {" and "Parse issue: Missing #end".
I've tried everything I can think of to fix this. I've checked the headers and #imports. I've moved all the classes into a new project thinking there was something wrong in the build settings. I even reinstalled Xcode to no avail. Here's the app delegate.h
#import <UIKit/UIKit.h>
#import "MainViewController.h"
#interface AppDelegate : UIResponder <UIApplicationDelegate> {
UIWindow *window;
MainViewController *viewController;
NSMutableArray *savedBookmarksArray;
}
#property (nonatomic) IBOutlet UIWindow *window;
#property (nonatomic) IBOutlet MainViewController *viewController;
#property (nonatomic) NSMutableArray *savedBookmarksArray;
#end
Every class that references the app delegate said the file could not be found. The .m is included in the Compile Sources. Anyone know how to fix this?
main.m
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
MainViewController.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "DDWebView.h"
#class AboutTableViewController;
#interface MainViewController : UIViewController <UIActionSheetDelegate, UIAlertViewDelegate, UIWebViewDelegate, UIPopoverControllerDelegate, UIScrollViewDelegate, UIGestureRecognizerDelegate> {
}
#end
I solved the issue. I had an import as #import "AppDelegate" instead of #import "AppDelegate.h" in one of my other headers.
Thanks for all your help guys!
..
I had a similar issue but it turned out that i accidentally declared the #interface inside the .m file and that screwed around with it. Once i removed it from the .m file it worked.
i've got own delegate for my own class.
MainMenuViewDelegate
#import <Foundation/Foundation.h>
#class MainMenuView;
#protocol MainMenuViewDelegate <NSObject>
-(void) mainMenuViewLibrary:(MainMenuView*)controller withString:(NSString*)string;
#end
MainMenuView.h
#import <UIKit/UIKit.h>
#import "WorkspaceView.h"
#import "MainMenuViewDelegate.h"
#interface MainMenuView : UIView
#property (nonatomic,weak) id <MainMenuViewDelegate> delegate;
....
#end
MainMenuView.m
#implementation MainMenuView
#synthesize delegate;
...
-(void)library:(id)sender{
//test
NSLog(#"it's work");
NSString *string = #"some text";
[delegate mainMenuViewLibrary:self withString:string];
NSLog(#"finish");
}
WorkspaceView.h
#import <UIKit/UIKit.h>
#import "MainMenuViewDelegate.h"
#interface WorkspaceView : UIView <MainMenuViewDelegate> {
int menuStatus;
UILabel *label;
}
#property int menuStatus;
#property (nonatomic, retain) UILabel *label;
#end
WorkspaceView.m
#import "WorkspaceView.h"
#import "MainMenuView.h"
#implementation WorkspaceView
#synthesize menuStatus;
#synthesize label;
....
-(void) mainMenuViewLibrary:(MainMenuView*)controller withString:(NSString*)string{
[label setText: string];
}
#end
The problem appears when i press btnLibrary and invokes -(void)library:(id)sender function.
console print it's work, then my delegate function is invokes, but i don't see any change in my label (placed in WorkspaceView), and in finish console print finish.
None of your objects is set as the delegate so the delegate is nil - messages sent to nil are silenced. Nothing happens.
If it is not a problem, put the NSLog in:
-(void) mainMenuViewLibrary:(MainMenuView*)controller withString:(NSString*)string;
in your WorkspaceView and check whether the method is called.
Hope that helps.