Parse Issue in AppDelegate.h - ios

I have the following code block, as the content of my AppDelegate.h of an iOS one view application:
//
// AppDelegate.h
// kompas
//
// Created by Attention8 Aps on 2/6/12.
// Copyright (c) 2012 Attention8. All rights reserved.
//
#import <UIKit/UIKit.h>
#class ViewController;
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#property (strong, nonatomic) ViewController *viewController;
#end
This yields the error "Expected identifed or '('" on the line
#class ViewController
I have tried comparing it with the AppDelegate.h from a newly started project, but I can't for the love of god spot the error. The mistake has arisen after tinkering with other files, but I can't seem to locate this issue.
Any help as to what could be the cause of this would be greatly appreciated.

It's probably a problem with another file. Try going through all your other classes and getting rid of any warnings/errors with them.

Try to open this file in vi. Sometimes invisible characters causes such errors.

Related

Cannot create new outlets in interface builder, old ones have a warning symbol

I am not sure what is causing this problem, but I now cannot create outlets. When I create an outlet it appears and works fine in code, but does not appear under the view controller in storyboard. Old outlets have a warning symbol on them like this
When I remove this outlet, its gone and does not appear back to connect. I am running Xcode beta 6.2 because moving to 6.2 temporarily fixed this problem because I was having it beforehand in 6.1.
Here is the .h file of this class
#import <UIKit/UIKit.h>
#interface DashboardViewController : UITableViewController {
NSString *currentDay;
}
#property (nonatomic, weak) IBOutlet UILabel *dayLabel;
#property (nonatomic, weak) IBOutlet UILabel *blockLabel;
#property (nonatomic, weak) IBOutlet UILabel *currentClassLabel;
#end
and here are the outlets listed in storyboard
These are the details of the warning, but this is .h file's code for this class
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#interface InfoViewController : UIViewController {
IBOutlet UIScrollView *AISScrollView;
IBOutlet MKMapView *AISMapView;
}
-(IBAction)studentHandbook:(id)sender;
#end
Oddly enough, I ended up finding a solution and that was moving the project out of the directory that it was in. It was in my Dropbox folder and moving it out fixed. If anyone has this problem in the future and also happens to have the proj in their Dropbox, move it out.
try to change this:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#interface InfoViewController : UIViewController {
IBOutlet UIScrollView *AISScrollView;
IBOutlet MKMapView *AISMapView;
}
-(IBAction)studentHandbook:(id)sender;
#end
to that:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#interface InfoViewController : UIViewController {
}
#property (nonatomic,weak) IBOutlet UIScrollView *AISScrollView;
#property (nonatomic,weak) IBOutlet MKMapView *AISMapView;
-(IBAction)studentHandbook:(id)sender;
#end
Just in case someone suffers from the same thing again, the best answer inside this other thread did the trick for me:
XCode 6: can't connect any IBOutlet to ViewController
Removing the .h and .m files from the project (their references) and readding them again was the solution that worked for me.

When creating a property for an instance of a viewController, the viewController cannot be found

I am trying to create a property for an instance of a viewController, like so,
#property (strong, nonatomic) DetailsViewController *videoViewController;
but I get an error saying that:
DetailsViewController is an unknown type name
The view controller is definitely imported like so,
#import "DetailsViewController.h"
Why is this happening?
To avoid Circular imports, always write Import statements in .m file, and use forward declaration in .h file.
In .h file
#class DetailsViewController;
In .m file
#import "DetailsViewController.h"
OR
For private properties, use Objective - C extensions, i.e,
Im .m file
#import "DetailsViewController.h"
#interface MasterViewController ()<YourProtocolList>
#property(nonatomic, strong) DetailsViewController *detailViewController;
#end
#implementation MasterViewController
//Your implementation stuff
#end
In case of inheritance, you may need to import in .h file.

Cannot find protocol declaration for 'MFMailComposeViewControllerDelegate'; did you mean 'UIPageViewControllerDelegate'?

This code :
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <MessageUI/MessageUI.h>
#import "MessageComposerViewController.h"
#import <MessageUI/MFMailComposeViewController.h>
#interface MapViewController : UIViewController <MFMailComposeViewControllerDelegate> // Add the delegate
- (IBAction)showEmail:(id)sender;
{
IBOutlet MKMapView *mapView;
}
#property (nonatomic, retain) MKMapView *mapView;
#end
This problem or error :
Cannot find protocol declaration for 'MFMailComposeViewControllerDelegate'; did you mean 'UIPageViewControllerDelegate'?
for this lign : #import "MessageComposerViewController.h"
Expected identifier or '('
for this lign : #interface MapViewController : UIViewController // Add the delegate
and this lign : {
Thanks for advance. :)
Try This,
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <MessageUI/MessageUI.h>
#import "MessageComposerViewController.h"
#import <MessageUI/MFMailComposeViewController.h>
#interface MapViewController : UIViewController <MFMailComposeViewControllerDelegate,UINavigationControllerDelegate> {
IBOutlet MKMapView *mapView;
}
- (IBAction)showEmail:(id)sender;
#property (nonatomic, retain) MKMapView *mapView;
#end
If you do the above and still see the warning in Xcode, try building or building & running your app. Sometimes these warnings linger after you've addressed the problem and are cleared out by a compilation cycle.
I encountered the same problem today coding an app for ios8.
First thing that I did was re-add the framework, but it didn't help. The problem was I ignored libAWDProtobufFacetimeiMessage - a protocol buffer file. I'm no professional to guess why, but when I added both buffer and the framework itself, the error message disappeared. I have posted a screenshot here. Hope my answer helps anyone looking here in the future.

Unknown type name while known?

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)

ios class not found "Expected a type"

I'm getting two problems in my FooterSelectorView.h and I have no idea why. One is a warning while the other is an error. For some reason xcode doesn't recognize FooterArchiveItemView so I'm not able to type my object as that which is causing other propblems. Has anyone ever seen anything like this before? How can I fix it?
FooterSelectorView.h
#import <UIKit/UIKit.h>
#import "FooterArchiveItemView.h"
#interface FooterSelectorView : UIImageView
// #warning Type of property 'activeItem' does not match type of accessor 'setActiveItem:'
#property (nonatomic, retain) FooterArchiveItemView *activeItem;
// #error Expected a type
- (void)setActiveItem:(FooterArchiveItemView *)activeItem_;
- (void)update;
- (CGPoint)absoluteCenterOf:(UIView *)obj;
#end
Related Classes
FooterArchiveItemView.h
#import <UIKit/UIKit.h>
#import "AutosizeableView.h"
#import "FooterArchiveView.h"
typedef void (^ DayBlock)(void);
#interface FooterArchiveItemView : AutosizeableView {
DayBlock dayBlock;
}
#property (nonatomic, retain) IBOutlet UIButton *day;
#property (nonatomic, retain) IBOutlet UIImageView *bullet;
- (void)setDayBlock:(DayBlock)block;
#end
AutosizeableView.h
#import <UIKit/UIKit.h>
#interface AutosizeableView : UIView
#end
One thing I'd suggest is that you conform to the Obj-C practice, that, within header interface files, rather than importing custom classes, you forward-declare them. For example, in FooterSelectorView.h, rather than:
#import "FooterArchiveItemView.h"
Forward-declare the class:
#class FooterArchiveItemView
Then, in the implementation file (FooterSelectorView.m), you import. Observing the practice may not actually solve your issue in this case (I don't know exactly what's happening, personally I'd want to see a bit more code to hazard a guess), but it might help isolate the issue for you.
The noted exception to this rule is Apple's frameworks - those are imported into headers.

Resources