When using Simperium in my app, the app quits with this error:
+[NSString sp_md5StringFromData:]: unrecognized selector sent to class 0x19fdfd8
I've debugged the code enough to know that it's crashing in the [[Simperium alloc] initWithViewController:controller] method, in the following code:
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UINavigationController *navController = (UINavigationController *)[tabBarController.viewControllers objectAtIndex:0];
NotesViewController *controller = (NotesViewController *)[[navController viewControllers] objectAtIndex:0] ;
self.simperium = [[Simperium alloc] initWithRootViewController:controller];
[self.simperium startWithAppID:#"my-app-ID-goes-here"
APIKey:#"the-API-key-would-go-here"
model:[self managedObjectModel]
context:[self managedObjectContext]
coordinator:[self persistentStoreCoordinator]];
I've concealed the AppID and API Key --- that's not a bug! :)
A required category for NSString isn't being loaded. This will happen if you forget to add -ObjC to "Other Linker Flags" under the build settings for your project. If you add that flag and run it again, I think you'll have better luck.
Related
My app is a single-view NavigationController as a root view controller style app. In it, I have a few different shortcut items for using 3D Touch. I have them all set up in the Info.plist fine (I've done this before with a Tab Bar app and it worked fine), but it crashes every time an shortcut action is pressed. Here is my the code used in AppDelegate in Obj-C.
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
UINavigationController *nav = (UINavigationController *) self.theMainView.view;
NSLog(#"%#", shortcutItem.type);
if ([shortcutItem.type isEqualToString:#"com.316apps.Fritch.inviteFriends"]) {
ImagePicker *vimeo= [[ImagePicker alloc] init];
[nav pushViewController:vimeo animated:YES];
}
if ([shortcutItem.type isEqualToString:#"com.316apps.Fritch.viewAlerts"]) {
NewsViewController *dvController8 = [[NewsViewController alloc] initWithNibName:#"NewsViewController" bundle:[NSBundle mainBundle]];
[nav pushViewController:dvController8 animated:YES];
}
if ([shortcutItem.type isEqualToString:#"com.316apps.Fritch.viewDirectory"]) {
DirectoryViewController *dvController8 = [[DirectoryViewController alloc] init];
[nav pushViewController:dvController8 animated:YES];
}
}
Crash Log:
com.316apps.Fritch.viewDirectory
2017-01-19 22:44:23.305906 Fritch[3956:925348] -[UILayoutContainerView pushViewController:animated:]: unrecognized selector sent to instance 0x101837530
2017-01-19 22:44:23.306768 Fritch[3956:925348] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UILayoutContainerView pushViewController:animated:]: unrecognized selector sent to instance
UINavigationController *nav = (UINavigationController *) self.theMainView.view;
The reason of crashing is you are getting the view, not ViewController. So self.theMainView.view cannot convert to UINavigationController. If your self.theMainView is correct, fix that crash by using:
UINavigationController *nav = (UINavigationController *) self.theMainView;
I am trying a tutorial for using story board from ray. I am using a tab bar controller connecting a tableview embedded with navigation controller, and this table view is named as players and a view controller connecting tab bar controller named as gestures. Displaying players game, name and rating in players tableview by storing those details in an object. So i have created a new file player with base object to store them as properties now i have to store those properties in an array of the view controller called player view controller and then i have to make the array and some test Player objects in the App Delegate and then assign it to the PlayersViewController’s players property using an instance variable.so In AppDelegate.m, i imported player and player view controller.h headers and add a new instance variable named _players. so my code in app delegate.m is as below the error is subscript requires size of interface 'NSARRAY' which is not constant in non-fragile ABI at the line viewcontrollers[0].
#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"
#implementation AppDelegate {
NSMutableArray *_players; }
#synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
_players=[NSMutableArray arrayWithCapacity:20];
player *player1=[[player alloc]init];
player1.name=#"name";
player1.game=#"cricket";
player1.rating=3;
[_players addObject:player1];
player1=[[player alloc]init];
player1.name=#"name";
player1.game=#"football";
player1.rating=3.5;
[_players addObject:player1];
player1=[[player alloc]init];
player1.name=#"tony";
player1.game=#"handball";
player1.rating=4;
[_players addObject:player1];
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UINavigationController *navigationController = [tabBarController viewControllers][0];
UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
Player view controller *playersViewController = [navigationController viewControllers][0];
playersViewController.players = _players;
return YES;
Using the subscript syntax (i.e. someArray[0]) requires Objective-C features that were introduced in the iOS 6 SDK, but afaik Xcode 4.2 only supports iOS 5, so you'd either have to use the old syntax:
UINavigationController *navigationController = [[tabBarController viewControllers] objectAtIndex:0];
//alternatively:
UINavigationController *navigationController = [[tabBarController viewControllers] firstObject];
...or update to a more recent version of Xcode (you can't even submit to the App Store with Xcode 4.2, as far as I'm aware).
If you're just trying to get the first object of the array, why not use firstObject?
UINavigationController *navigationController = [[tabBarController viewControllers] firstObject];
You can use below code
UINavigationController *navigationController =
[tabBarController.viewControllers objectAtIndex:0];
Refer the below links..regarding error and explanation..!
What is a non-fragile ABI?
Subscript requires size of interface 'NSArray', which is not constant in non-stable ABI
Hope it helps you...!
Hey together,
I am calling a void with some parameters from the AppDelegate on my main view.
This is done if a push notification is received:
MainViewController *mainView = [[MainViewController alloc] init];
[mainView showPushView:pushDataObject];
The called void # the MainView doing some data operating stuff and after that it should load the pushView:
- (void)showPushView: (PFObject *)pushDataObject {
NSLog(#"Push Data object transfered %#", pushDataObject);
pushItem = pushDataObject;
//All working fine to this point
[self performSegueWithIdentifier:#"showPushObject" sender:self];
}
Now the problem is that the app is crashing at [self performSegueWithIdentifier:#"showPushObject" sender:self]; with this Error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'Receiver (<MainViewController: 0x145b80e0>) has no segue with identifier 'showPushObject''
*** First throw call stack:
(0x2e51fe83 0x3887c6c7 0x30f656d9 0xbeb11 0xb2a23 0x1745f7 0x38d610c3 0x38d610af 0x38d639a9 0x2e4ea5b1 0x2e4e8e7d 0x2e453471 0x2e453253 0x3318d2eb 0x30d08845 0xafecd 0x38d75ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
I think that there is a problem because I call the void from the AppDelegate, am I right?
Those anyone know a fix for that problem?
Thanks a lot!
Best regards from Germany :)
P.S. If I call [self performSegueWithIdentifier:#"showPushObject" sender:self]; with a button or something on the MainViewController all working fine... :/
In order for the segue to work, you need to have the storyboard loaded in the mainView when you start it that way. Try instead something like this:
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
UIViewController *firstViewController = [storyboard instantiateViewControllerWithIdentifier:#"kYourMainViewControllerIdentifier"];
self.window.rootViewController = firstViewController;
[self.window makeKeyAndVisible];
Remember to give an identifier to your root view controller and change it in this piece of code.
Your problem is this line:
MainViewController *mainView = [[MainViewController alloc] init];
because it means that the mainView instance doesn't have a storyboard (so it can't have any segues).
When you run it from a button the controller instance must have been created from a storyboard.
So, to fix, load the storyboard and instantiate mainView from it. Then the segue will work.
UIStoryboard *storyboard4Inch = [UIStoryboard storyboardWithName:#"Storyboard4Inch" bundle:nil];
UIViewController *mainViewController = [storyboard4Inch instantiateViewControllerWithIdentifier:#"MainViewController"];
[mainViewController showPushView:pushDataObject];
I started a Master-Detail Application in X-Code. I chose the options to be universal, core data, and git repo. When the application comes up, I went into the iphone story board, added a tab view controller, moved the nav/table/detail views it starts with to be in the tab controller as the third tab (in reality I want it to be the fourth). I then chose the tab controller to be the initial view the program should start with when in iphone mode. It builds successfully but does not allow the program to finish loading. The error that comes out is recorded below:
2013-05-11 21:35:00.302 FearlessAndThorough[6318:907] -[UITabBarController topViewController]: unrecognized selector sent to instance 0x1c592020
2013-05-11 21:35:00.306 FearlessAndThorough[6318:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITabBarController topViewController]: unrecognized selector sent to instance 0x1c592020'
*** First throw call stack:
(0x337f33e7 0x3b4ee963 0x337f6f31 0x337f564d 0x3374d208 0xc9e43 0x35662aa1 0x35662625 0x3565a833 0x35602d1f 0x356027ad 0x356021ef 0x3731a5f7 0x3731a227 0x337c83e7 0x337c838b 0x337c720f 0x3373a23d 0x3373a0c9 0x3565946d 0x356562b9 0xc9ab5 0x3b91bb20)
libc++abi.dylib: terminate called throwing an exception
(lldb)
I am hoping that someone has done this before and can give me a little insight as to the proper procedure or steps to take when setting up a tab view controller type app that will then convert into a master detail application for ipad.
Here is the current app delegate's didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
splitViewController.delegate = (id)navigationController.topViewController;
UINavigationController *masterNavigationController = splitViewController.viewControllers[0];
MasterViewController *controller = (MasterViewController *)masterNavigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
} else {
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
MasterViewController *controller = (MasterViewController *)navigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
}
return YES;
}
Your problem is that you added a tab bar controller to the front of your iPhone storyboard, but in your "else" clause you say the root view controller of the window is a navigation controller -- it's not, the tab bar controller that you added is. If you put a log in as the second line in that else clause, you will see that navigationController is actually a tab bar controller, not a navigation controller. That else clause needs to look like this:
UITabBarController *tbc = (UITabBarController *)self.window.rootViewController;
UINavigationController *navigationController = tbc.viewControllers[3];
MasterViewController *controller = (MasterViewController *)navigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
I'm not sure about the "3" in tbc.viewControllers. I can't tell from your description which tab that navigation controller is in, so you might need to change that.
I think I got your problem.
Did you use a UITabbar object in the Xcode navigator :
Because to manage views with a TabbarController, the best way is to embed your view in a Navigation Controller, like below :
Then you got your first view embedded in a navigation controller :
You can now add a new viewController in the field and add it to the TabbarController by control-dragging from the TabbarController and select the Relationship item :
Then you got 2 views in a navigationController :
And nothing to do in the appDelegate.
Then do the last step for any other view you want embedded in the navigationController.
Hope this helps.
// Change your else part in appdelegate to this it may works.
else {
UITabBarController *tabBarController = (UITabBarController *) self.window.rootviewController;
// For third view in tabbar controller
UINavigationController *navigationController = [tabBarController viewControllers] objectAtIndex: 2];
navigationController = (UINavigationController *)self.window.rootViewController;
MasterViewController *controller = (MasterViewController *)navigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
}
I'm trying to use CoreData with Storyboard on a TabBar - NavigationController - TableViewController configuration.
When trying to assign the Managed Object Context to the TableViewController I get
[UITabBarController topViewController]: unrecognized selector sent to instance
If I understand correctly, the problem is that I'm not getting the TableViewController instance. I've tried many things but I don't seem to be getting anywhere.
Your help is much appreciated.
I was able to fixit using Matthijs Hollemans tutorial on raywenderlich.com.
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UINavigationController *navigationController = [[tabBarController viewControllers] objectAtIndex:0];
MyViewController *controller = [[navigationController viewControllers] objectAtIndex:0];
controller.managedObjectContext = self.managedObjectContext;