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>
Related
When I define my block in my .h file, there comes an issue:
Unknown type name NSString
My code is below:
typedef void(^CancelBlock)();
typedef void(^ConfirmBlck)(NSString *); // this line comes the error
#import <UIKit/UIKit.h>
#interface LMLUpspringView : UIView
#property (nonatomic, copy) CancelBlock cancelBlock;
#property (nonatomic, copy) ConfirmBlck confirmBlock;
#end
But, why is my first block ok and the second report's an error?
You define block above the #import <UIKit/UIKit.h> (in the .h file), so there did not import the NSString, you should cut the #import <UIKit/UIKit.h> above the block define.
you need to declare block as below
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef void(^ConfirmBlck)(NSString * string);
In latest versions of xcode you can simply specify
#import <Foundation/NSString.h>
any NS Foundation class can be imported as needed.
position declaration uikit import then follow:
// declare
#property(nonatomic,strong)void(^ConfirmBlck)(NSString * string);
// define
[self setConfirmBlck:^(NSString *indexpVal) { }];
// call
if (self.ConfirmBlck) {
self.ConfirmBlck(selectedVal);
}
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 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
Xcode has showed out of the blue this error: "Unknown type name"
I'll explain:
My StoriesViewController.h:
#import <UIKit/UIKit.h>
#import "Stories.h"
#interface StoriesViewController : UIViewController <UITextViewDelegate>
#property (strong) Stories *story; //Here it goes- "Unknown type name `Stories`"
#property (weak) IBOutlet UITextView *storyView;
#end
In my Stories.h:
#import <UIKit/UIKit.h>
#import "ViewController.h"
#interface Stories : UIDocument
#property (strong) NSString * storyContent;
#end
Again, out of the blue.
Thanks in advance.
EDIT:
In my ViewController.h:
#import <UIKit/UIKit.h>
#import "Stories.h"
#import "StoriesViewController.h"
#import "StoriesPickerViewController.h"
#import <QuartzCore/QuartzCore.h>
#interface ViewController : UIViewController <UITextFieldDelegate, UIAlertViewDelegate> {
}
#end
NB #class throws loads of ARC issues.
I have removed useless references to ViewController.h, worked.
SOLVED!
You have a circular reference problem.
What's happening is that when you load your ViewController it goes through it's imports, it loads Stories.h, it goes to load it's imports and it goes back to ViewController.h, so you are stuck in an infinite loop there.
Either remove one of the conflicting imports, or use forward class declaration (that example is for C++, see here for an example with Objective-C)
it did it so many times and i didn't had any problems with it, but this time i still getting the error above, my relevant code is this:
#import "PiecesChoisies.h"
#interface SelectionMobilier : UIViewController {
IBOutlet PiecesChoisies *piecesChoisies;//Error: Expected specifier-qualifier-list before PiecesChoisies
}
#end
Thanx in advance for any suggestions :)
EDIT :
I try this :
#import "PiecesChoisies.h"
#interface SelectionMobilier : UIViewController {
IBOutlet NSString *piecesChoisies;//Error: Expected specifier-qualifier-list before PiecesChoisies
}
#end
Now i got this stack:
PiecesChoisies is not recognized as a type. This may happen because it has cyclical dependencies.
The following code example illustrates the problem. Classes A and B create a circular dependency trying to import each other.
#import "B.h" // <-- A imports B
#interface A : NSObject
#end
#import "A.h"
#implementation A
#end
#import "A.h" // <-- and B imports A
#interface B : NSObject
#end
#import "B.h"
#implementation B
#end
Because the classes are never created, the compiler treats them as unknown tokens, so the error shows as Expected specifier-qualifier-list before XXX. In other words "I expected something meaningful before XXX".
To remove the circular dependency:
And add a forward class declaration (#class) on the interface file.
Move the #import from the interface to the implementation file.
The class declaration tells the compiler "don't worry, I'll define this later", so the header becomes safe to import because the conflicting definition is now out of sight on the implementation file.
Here is the result for the previous example:
#class B; // <---- #import "B.h" replaced with #class B
#interface A : NSObject
#end
#import "A.h"
#import "B.h" // <---- #import "B.h" added
#implementation A
#end
And do the same with class B:
#class A; // <---- #import "A.h" replaced with #class A
#interface B : NSObject
#end
#import "B.h"
#import "A.h" // <---- #import "A.h" added
#implementation B
#end
The problem will be located in PiecesChoisies.h. Change:
IBOutlet PiecesChoisies *piecesChoisies;
to
IBOutlet NSString *piecesChoisies;
that will confirm that the problem is located in the .h file.
If this is in a header file, use
#class PiecesChoisies;
Instead of the import statement. Import the .h file in your .m file.