New to iOS development. The problem I'm getting is that #import Foundation; is running the error:
illegal interface qualifier
Code in WXClient.h:
#import <Foundation/Foundation.h>
#import CoreLocation;
#import <ReactiveCocoa.h>
#interface WXClient : NSObject
#import Foundation;
- (RACSignal *)fetchJSONFromURL:(NSURL *)url;
- (RACSignal *)fetchCurrentConditionsForLocation:(CLLocationCoordinate2D)coordinate;
- (RACSignal *)fetchHourlyForecastForLocation:(CLLocationCoordinate2D)coordinate;
- (RACSignal *)fetchDailyForecastForLocation:(CLLocationCoordinate2D)coordinate;
#end
You can't put your #import inside your class declaration. Put it with the rest of your imports. Additionally, if you're going to import Foundation as a module, there's no need to have this import #import <Foundation/Foundation.h> at all.
#import Foundation;
#import CoreLocation;
#import <ReactiveCocoa.h>
#interface WXClient : NSObject
- (RACSignal *)fetchJSONFromURL:(NSURL *)url;
- (RACSignal *)fetchCurrentConditionsForLocation:(CLLocationCoordinate2D)coordinate;
- (RACSignal *)fetchHourlyForecastForLocation:(CLLocationCoordinate2D)coordinate;
- (RACSignal *)fetchDailyForecastForLocation:(CLLocationCoordinate2D)coordinate;
#end
Related
Having issue with defining a native module from the tutorial in https://facebook.github.io/react-native/docs/native-modules-ios.html.
#import "CalendarManager.h"
#import <React/RCTLog.h>
#implementation CalendarManager
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(addEvent: (NSString *)name location: (NSString *)location)
{
}
#end
It give me the compile error in RCT_EXPORT_METHOD saying
"Expected ')'"
.
and
'Type specifier missing, defaults to int' (later also appeared under
RCT_EXPORT_MODULE)
You need to insert #import <React/RCTBridgeModule.h> in CalendarManager.h either.
Like this
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
NS_ASSUME_NONNULL_BEGIN
#interface CalendarManager : NSObject<RCTBridgeModule>
#end
NS_ASSUME_NONNULL_END
I am trying to figure out how to take the delegate in LocationViewController and SetScoringTableViewController and implement both of them in GameDetailsTableViewController. LocationViewControllerDelegate was already working, but when I added the new SetScoringTableViewController, the program had an error.
LocationViewController.h
#import "ViewController.h"
#class LocationViewController;
#protocol LocationViewControllerDelegate <NSObject>
- (void)addItemViewController:(LocationViewController *)controller didFinishEnteringItem:(NSString *)name;
#end
#interface LocationViewController : UIViewController
#property (nonatomic, weak) id <LocationViewControllerDelegate> delegate;
#end
SetScoringTableViewController.h
#import <UIKit/UIKit.h>
#import "GameDetailsTableViewController.h"
#import "LocationViewController.h"
#class SetScoringTableViewController;
#protocol SetScoringTableViewControllerDelegate <NSObject>
- (void)addItemViewControllerSS:(SetScoringTableViewController *)SScontroller didFinishEnteringItemSS:(NSString *)SSname;
#end
#interface SetScoringTableViewController : UITableViewController
#property (nonatomic, strong) id <SetScoringTableViewControllerDelegate> SSdelegate;
#end
GameDetailsTableViewController.h
#import <UIKit/UIKit.h>
#import "LocationViewController.h"
#import "SetScoringTableViewController.h"
#interface MainViewController : UITableViewController <LocationViewControllerDelegate, SetScoringTableViewControllerDelegate>
When I run this I get an error: "Cannot find protocol declaration for 'SetScoringTableViewControllerDelegate' even though I have.
The only way I have found to fix this problem is to put the "SetScoringTableViewController delegate in the LocationView Controller, but I know that is not right. Any help would be greatly appreciated.
You have a dependency loop:
SetScoringTableViewController.h
#import "GameDetailsTableViewController.h"
GameDetailsTableViewController.h
#import "SetScoringTableViewController.h"
But it looks like you can remove the #import "GameDetailsTableViewController.h" as there is no mention of it in the header file.
What you're experiencing is an an #import cycle. To break the import loop
remove this import line:
#import "GameDetailsTableViewController.h"
from SetScoringTableViewController.h and put it in a .m file.
Try to separate the delegate on a different .h file.
I plan to make a QRBar scanner, I found a source called "IOS7_BarcodeScanner" which implement the any types of scanner to be used. I try the demo sources, and it works like a charm. But when I comes to creating my own project, and implement it. Unknown types name UIBezierPath, even I copy and paste exactly the files from demo source. It doesn't work. I have import the frameworks accordingly.
Barcode.h
#import <Foundation/Foundation.h>
#import AVFoundation;
#interface Barcode : NSObject
+ (Barcode * )processMetadataObject:(AVMetadataMachineReadableCodeObject*) code;
- (NSString *) getBarcodeType;
- (NSString *) getBarcodeData;
- (void) printBarcodeData;
#end
Barcode.m
#import "Barcode.h"
#interface Barcode()
#property (nonatomic, strong) UIBezierPath *cornersPath;
#end
#implementation Barcode
#end
Error
#property (nonatomic, strong) UIBezierPath *cornersPath;
Message
Unknown type name 'UIBezierPath'
Property with 'retain (or strong)' attribute must be of object type'
Import UIKit framework
Objective-C :
#import <UIKit/UIKit.h> OR #import UIKit;
Swift
import UIKit
Try adding this at the top of your .h file:
#import <UIKit/UIKit.h>
When I tried having protocols in below two classes, compiler says that the protocol declarations cannot be found
ViewController:
#import <UIKit/UIKit.h>
#import "SecondViewController.h"
#protocol FlipOtherSideViewControllerDelegate;
#interface ViewController : UIViewController<FlipsideViewControllerDelegate> {
id <FlipOtherSideViewControllerDelegate> __unsafe_unretained delegate;
}
- (IBAction)switchMode:(id)sender;
#property (unsafe_unretained) id <FlipOtherSideViewControllerDelegate> delegate;
#end
#protocol FlipOtherSideViewControllerDelegate
- (void)flipothersideViewControllerDidFinish:(ViewController *)controller;
#end
SecondViewController:
#import <UIKit/UIKit.h>
#import "ViewController.h"
#protocol FlipsideViewControllerDelegate;
#interface SecondViewController : UIViewController <FlipOtherSideViewControllerDelegate> {
id <FlipsideViewControllerDelegate> __unsafe_unretained delegate;
}
#property (unsafe_unretained) id <FlipsideViewControllerDelegate> delegate;
#end
#protocol FlipsideViewControllerDelegate
- (void)flipsideViewControllerDidFinish:(SecondViewController *)controller;
#end
Any suggestion on above?
Thanks in advance.
Why you declaring below the interface? Try to declare just before the interface declaration. I think there should not be any error then.
I was creating an NSObject class for doing web service. But while creating the protocol ,an error comes displaying"cannot find protocol declaration for NSObject" .In Xcode 4 I never came across such problems.Now I am using Xcode 6. Pls help me. Code is as below.
#protocol web <NSObject>
-(void)(NSArray *)urlArray;
#end
#import <Foundation/Foundation.h>
#interface Webclass : NSObject
#end
Write your protocol under #import and put name on your method
#import <Foundation/Foundation.h>
#protocol web <NSObject>
-(void)methodName:(NSArray *)urlArray;
#end
#interface Webclass : NSObject
#end