Xcode 5.1.1 AppDelegate.h and main.m error - ios

I created a project a few week ago and opened it today. When i left the project there were no errors and everything worked fine, but now i have three errors and don't know why.
Here my AppDelegate.h :
#import <UIKit/UIKit.h>
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#end
And here my main.m:
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
Here the errors:
/main.m: Semantic Issue Use of undeclared identifier 'AppDelegate'
AppDelegate.h: Parse Issue Expected identifier or '('
AppDelegate.h: Parse Issue '#end' must appear in an Objective-C context

Related

Apple Mach-O Linker (Id) Error when i import a .h class file

i have a view controller called ViewController and it works with my app perfectly, but in my other viewControllers i needed to push the initial ViewController, to when i import the ViewController as below:
#import "AlbumsUtilities.h"
#import "PhotosUtilities.h"
#import "MyProgressHUD.h"
#import "CommonFunctionalities.h"
#import "AlbumDetailsViewController.h"
--->#import "ViewController.h"
#interface SettingsViewController ()
#property (nonatomic, strong) NSMutableArray<AlbumsUtilities *> *userAlbums;
#property (nonatomic, assign, getter=isReSequence) BOOL reSequence;
#end
i get the Apple Mach-O Linker (Id) Error, any ideas?

Unknown type name 'NSString' when I define a block

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);
}

Accessing an externed variable from objective-c in swift

I have an iOS project that uses both Obj-C and Swift.
In main.m, I want to instantiate a variable to be accessed by Swift. The specific use case is to store the absolute time at main, and then measure time elapsed since main elsewhere.
Here's what my relevant files look like:
main.m
#import <UIKit/UIKit.h>
CFAbsoluteTime StartTime;
int main(int argc, char* argv[])
{
StartTime = CFAbsoluteTimeGetCurrent(); // This is what I want to access elsewhere.
#autoreleasepool {
...
}
}
myapp-Bridging-Header.h
#import "AppDelegate.h"
extern CFAbsoluteTime StartTime;
AppDelegate.h
#import <UIKit/UIKit.h>
extern CFAbsoluteTime StartTime;
#interface AppDelegate : NSObject <UIApplicationDelegate>{}
#property (nonatomic, strong) IBOutlet UIWindow* window;
// ... other irrelevant #property
#end
And then in the actual .swift file, I'm just trying to access StartTime without declaring anything (as I thought it worked since it's being externed), but I'm getting an unresolved identifier error.

Thread 1: signal SIGABRT - AppDelegate.h

//
// main.m
// Journey
//
// Created by Julian Buscema on 2014-07-13.
// Copyright (c) 2014 Julian Buscema. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
When I try running my application, my main.m opens up and the "return UIApplicationMain...." line is highlighted in green saying thread 1: signal SIGABRT. I googled it and it says that it has to do with my AppDelegate.h file but which part of it?
Here it is:
//
// AppDelegate.h
// Journey
//
// Created by Julian Buscema on 2014-07-13.
// Copyright (c) 2014 Julian Buscema. All rights reserved.
//
#import <UIKit/UIKit.h>
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#end
Your error says this class is not key value coding-compliant for the key username.
Something is not right with element named username. Did you create outlets from Storyboard to your ViewController? If you you did, are you renamed property in ViewController?
Try right clicking on UITextField and check outlets. Empty white circle means your outlet is broken, it must be white.

Thread 1 received signal SIGABART error

Im getting the following error when hitting the email button in my application on the simulator. Im using the same code form a previous application so the code must be ok
int main(int argc, char *argv[])
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
Im having trouble interpreting what this means, the debugger says
argc = (int)1
argv = (char**) 0Xbffff594
*argv = char 0xbffff6b8/users/library/apllications/5.1/applications/FBA888AA-xxxxxx
In thread 1
0x0028b626 <+1163> xor %eax,%eax
0x951929c6 <+0010> jae 0x951929d6 <__pthread_kill+26>
I have rebooted machine, still same error
Could anyone offer any advice?
Add this line to your App-delegate in .h file#property (strong, nonatomic) ViewController *viewController;
and this line to your App-delegate .m file #synthesize viewController = _viewController;
Add this line to your App-delegate in .h file
#property (strong, nonatomic) UIViewController *viewController;
and this line to your App-delegate .m file
#synthesize viewController = _viewController;
It looks like you may have a connection broken. You should double check all your connections in Interface Builder.
Re-connect your connection or delete the connection.

Resources