i got a questions when i use iOS-Universal-Framework - iphone

The iOS-Universal-Framework's page : https://github.com/kstenerud/iOS-Universal-Framework
I have build my framework by use this template,i have pack all my class in the template,
but i got a problem,there some third-party framework that i want put in my framework depend on Appdelegate,but there is no Appdelegate class in the the iOS-Universal-Framework project,so i tried to add a "MyAppdelegate" class in my framework project
//
// MyAppdelegate.h
// ZPFramework
//
// Created by Jin XuDong on 13-11-30.
// Copyright (c) 2013年 Jin XuDong. All rights reserved.
//
#import <UIKit/UIKit.h>
#interface MyAppdelegate : UIResponder<UIApplicationDelegate>
#end
//
// MyAppdelegate.m
// ZPFramework
//
// Created by Jin XuDong on 13-11-30.
// Copyright (c) 2013年 Jin XuDong. All rights reserved.
//
#import "MyAppdelegate.h"
#implementation MyAppdelegate
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
// do somethinig depandes on appdelegate
}
#end
,then i inherit MyAppdelegate in my project which use my ZPFramework,
#import <UIKit/UIKit.h>
#import <ZPFramework/MyAppDelegate.h>
#interface AppDelegate :MyAppDelegate <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#end
but..it crashed immediately when the project run
2013-11-30 10:46:16.771 维派[181:60b] -[AppDelegate setWindow:]: unrecognized selector sent to instance 0x1655ebc0
2013-11-30 10:46:16.779 维派[181:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate setWindow:]: unrecognized selector sent to instance 0x1655ebc0'
*** First throw call stack:
(0x30970f4b 0x3ad006af 0x309748e7 0x30973069 0x308c24d8 0x8767b 0x331542ff 0x33153d4f 0x3314e353 0x330e941f 0x330e8721 0x3314db3d 0x3558470d 0x355842f7 0x3093b9df 0x3093b97b 0x3093a14f 0x308a4c27 0x308a4a0b 0x3314cdd9 0x33148049 0x80e09 0x3b208ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
i don't know why,please help me,thanks.

Related

IOS Segue - Terminating app due to uncaught exception 'NSGeneric Exception'

Storyboard screenshot
In the Xcode 4.6 Storyboard i've 2 ViewControlers, one which holds the buttons and the other a labelView, passing a string "Home Tapped" on the tap of the home button
Heres the ViewController.m code
#import "ViewController.h"
#import "ViewController2.h"
#interface ViewController ()
#end
#implementation ViewController
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:#"Home"])
{
NSString *message = #"Tapped on home";
ViewController2 *vc = [segue destinationViewController];
vc.labelString = message;
}
}
ViewController2.h
#import <UIKit/UIKit.h>
#interface ViewController2 : UITableViewController
#property(nonatomic,strong) UILabel *mylabel;
#property(nonatomic,strong) NSString *labelString;
#end
And the error
Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'Home'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
*** First throw call stack:
(0x1c91012 0x10cee7e 0x468f31 0x45ab99 0x45ac14 0x10e2705 0x162c0 0x16258 0xd7021 0xd757f 0xd66e8 0x45cef 0x45f02 0x23d4a 0x15698 0x1becdf9 0x1becad0 0x1c06bf5 0x1c06962 0x1c37bb6 0x1c36f44 0x1c36e1b 0x1beb7e3 0x1beb668 0x12ffc 0x28dd 0x2805)
libc++abi.dylib: terminate called throwing an exception
(lldb)
You need to make your NavigationController the entry point for your storyboard. Right now it is View Controller, which is indicated by the arrow pointing to it with no source.

Getting the error (breakpoint) "Thread 1: signal SIGBRT"

While trying to run my tab-bar app with many different features such as UITableView and mapview with a annotation, I recently added a webview on my first tab in my firstviewcontroller. As far as I know, there's nothing wrong with the coding there, though ever since I tried adding the webview on my first tab I keep getting the breakpoint/error while trying to run the app : Thread 1: signal SIGBRT.
I've read around some, and someone said that if I change mi xib file /storyboard's deployment to iOS 5.0 instead of 6.0 (wich I'm currently using) and not having "Use Autolayout" checked it should get rid of it. Though It didn't. Any thoughts or solutions to this?
Here's the coding for my firstviewcontroller.h
#import <UIKit/UIKit.h>
#interface FirstViewController : UIViewController
#property (weak, nonatomic) IBOutlet UIWebView *webView;
#end
firstviewcontroller.m
#import "FirstViewController.h"
#interface FirstViewController ()
#end
#implementation FirstViewController
#synthesize webView;
- (void)viewDidLoad
{
NSString *website = #"http://www.google.com";
NSURL *url = [NSURL URLWithString:website];
NSURLRequest *requestUrl = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestUrl];
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#end
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's where it says SIGBRT
}
}
All output:
2013-01-04 11:27:06.697 My Corp[784:13d03] Unknown class ViewController in Interface Builder file.
2013-01-04 11:27:06.716 My Corp[784:13d03] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<FirstViewController 0x808fbf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key myWebView.'
*** First throw call stack:
(0x1800012 0x11c5e7e 0x1888fb1 0xc72711 0xbf3ec8 0xbf39b7 0xc1e428 0x32a0cc 0x11d9663 0x17fb45a 0x328bcf 0x1ede37 0x1ee418 0x1ee648 0x1ee882 0x20fed9 0x20fd14 0x20e1ea 0x20e06c 0x20c1cc 0x20c9b6 0x1f0753 0x1f0a7b 0x1f1964 0x154877 0x15b5a3 0x153eed 0x13db56 0x13ddbf 0x13df55 0x146f67 0x10afcc 0x10bfab 0x11d315 0x11e24b 0x10fcf8 0x1cc9df9 0x1cc9ad0 0x1775bf5 0x1775962 0x17a6bb6 0x17a5f44 0x17a5e1b 0x10b7da 0x10d65c 0x289d 0x27c5)
libc++abi.dylib: terminate called throwing an exception
(lldb)
The mistake you have done was clearly stated in the crash report
[<FirstViewController 0x808fbf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key myWebView.'
To solve that go to your XIB of that Class right click on the File owner located on the left side pane of InterfaceBuilder. You will find an object with name myWebView with yellow warning icon, click remove on that outlet connection and compile your code. You have connected the outlet and later you remove the IBOutlet in the code and forget to remove the connection in the XIB.
set
UIWebViewDelegate in .h file and in xib attach delegate of webview

"Unrecognizer selector sent to class" on class category after importing framework

After adding MessageUI.framework to my Xcode (4.3.2) iOS project I get:
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '+[Message responseArrayKey]: **unrecognized selector sent to class ..
for one of my class extensions.
Message class is simply NSManagedObject subclass and I have category NSManagedObject(Synchronize) on it:
//
// Message.h
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "NSManagedObject+Synchronize.h"
#class Message;
#interface Message : NSManagedObject {
#private
}
...
#end
//
// NSManagedObject+Synchronize.h
#interface NSManagedObject (Synchronize)
+(NSString *)responseArrayKey;
#end
To be clear: The code worked before and I have Linker flags set to: -Obj-C and -all_load. (Followed: http://developer.apple.com/library/mac/#qa/qa1490/_index.html)
Somehow thou - this framework breaks the linking. What is so special in this framework? I am using many more framework and none of them is causing the issue.
I have repaired the issue by refactoring my Message class to CDMesage. Looks like there was class name clash with MessageUI framework.

Creating an iPhone Application in Xcode 4.1.1 - Program received signal "SIGABRT"

I'm new to creating iPhone Applications and have just started with Xcode and am getting the following errors; I have used this code previously on both the simulator & an iPod touch and it worked fine for both but for some reason lately it will not allow me to go from one page to another without giving me the "SIGABRT" error.
Basically in my application I need to go from one page to another several times but it will not work....can anyone help with this please?
This is the code it seems unhappy with (it complies & builds successfully):
1 #import <UIKit/UIKit.h>
2
3 int main(int argc, char *argv[])
4 {
5 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
6 int retVal = UIApplicationMain(argc, argv, nil, nil);
7 [pool release];
8 return retVal;
9 }
It stops on the int retVal line (6th line).
When debugging it gave the error:
2011-09-09 15:33:59.029 TruckFile[1072:b603] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[< UIApplication 0x6044600> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key window.'
Can anyone help me with this please?
Thank you in advance!
========================================
Code files:
========================================
Main page (.h)
#import <UIKit/UIKit.h>
#import "ViewTwoController.h"
#import "TruckFileAppDelegate.h"
#interface TruckFileAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
ViewTwoController *viewTwoContoller;
UINavigationController *navigationController;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
#property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext;
#property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel;
#property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
#property (nonatomic, retain) ViewTwoController *viewTwoController;
-(IBAction)switchPage:(id)sender;
#end
================================================
Main page (.m)
#import "TruckFileAppDelegate.h"
#import "ViewTwoController.h"
#implementation TruckFileAppDelegate
#synthesize window;
#synthesize navigationController;
#synthesize managedObjectContext = __managedObjectContext;
#synthesize managedObjectModel = __managedObjectModel;
#synthesize persistentStoreCoordinator = __persistentStoreCoordinator;
#synthesize viewTwoController;
-(IBAction)switchPage:(id)sender
{
if(self.viewTwoController == nil)
{
ViewTwoController *viewTwo = [[ViewTwoController alloc]
initWithNibName:#"ViewTwoController" bundle:[NSBundle mainBundle]];
self.viewTwoController = viewTwo;
[viewTwo release];
}
[self.navigationController pushViewController:self.viewTwoController animated:YES];
}
- (void)dealloc {
[navigationController release];
[window release];
[super dealloc];
}
#end
====================================
Page 2 (.h)
#import <UIKit/UIKit.h>
#interface ViewTwoController : UIViewController {
}
#end
=====================================
Page 2 (.m)
#import "ViewTwoController.h"
#implementation ViewTwoController
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}
- (void)dealloc {
[super dealloc];
}
#end
The mainWindow.xib is trying to connect it's UIWindow instance with your UIApplicationDelegate's and it can't find it (that's why it complains it can't set the value for an UNDEFINED key).
Check your UIApplicationDelegate class has a UIWindow iVar, a property in its .h and it's correctly synthesized in its .m.
EDIT
Who's calling the method switchPage: on UIApplication? If you are, you're calling it on the wrong object. Instead of doing
[[UIApplication sharedApplication] switchPage:xxx];
You should do:
[[[UIApplication sharedApplication] delegate] switchPage:xxx];
Since the method switchPage: is defined in the UIApplicationDelegate class.
Your code fails at
[UIApplication switchPage:]:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIApplication switchPage:]: unrecognized selector sent to instance 0x600beb0'
This means that in your switchPage method, you are giving an action to an unknown identifier, maybe check the object identifier name, and check if you have initialized it in your .h file.

ModalViewController delegate confusion

I need to present a modal view controller and be notified when it is dismissed or notified that I need to dismiss it, looking here I am still confused:
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html#//apple_ref/doc/uid/TP40007457-CH111-SW14
I have my mainViewController and myModalView controller and I have the following code that needs to be implemented but not sure where - first up delegate protocal:
#protocol DataSyncDelegate <NSObject>
-(void) doneWithSync;
#end
which controller.h does this go in? I am assuming my modalViewController.h
second is my implementation:
-(void) doneWithSync {
[self dismissModalViewControllerAnimated:YES];
}
which controller.m does this go in? I am assuming my mainViewController.m
I also have the delegate properties that needs to be aded:
id delegate;
#property (nonatomic, retain) id delegate;
which controller.m does this need to go in? I am assuming my modalViewController.h
and here is how I am presenting the modalViewController from my MainViewController:
DataSyncViewController *dataSyncViewController = [[DataSyncViewController alloc] initWithOptions:FALSE];
dataSyncViewController.delegate = self;
[self presentModalViewController:dataSyncViewController animated:NO];
[dataSyncViewController release];
As of right now this gives me the following error:
-[DataSyncViewController setDelegate:]: unrecognized selector sent to instance 0x5952e20
What am I missing here?
EDIT - HERE IS MY MODAL VIEW CONTROLLER .H
#import <UIKit/UIKit.h>
#protocol DataSyncDelegate
-(void) doneWithSync;
#end
#interface DataSyncViewController : UIViewController {
id <DataSyncDelegate> delegate;
}
#property (nonatomic, retain) id <DataSyncDelegate> delegate;
#end
EDIT - MAIN VIEW CONTROLLER .H AND .M
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import "DataSyncViewController.h"
#interface LoginViewController : UIViewController <DataSyncDelegate>{
}
#end
HERE IS THE CREATION OF THE MODAL:
DataSyncViewController *dataSyncViewController = [[DataSyncViewController alloc] initWithOptions:FALSE];
dataSyncViewController.delegate = self;
[self presentModalViewController:dataSyncViewController animated:NO];
[dataSyncViewController release];
HERE IS MY IMPLEMENTATION OF THE DELEGATE:
-(void) doneWithSync {
[self dismissModalViewControllerAnimated:YES];
}
And now everything looks to wire up correctly in the compiler but I get the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[DataSyncViewController setDelegate:]: unrecognized selector sent to instance 0x59e4b40'
Your main view controller IS the delegate and should implement the protocol. Your modalView has a delegate that it calls when it is being dismissed.