Kodeco Forums

iOS Tutorial: How To Create A Simple iPhone App: Part 1/3

An iOS tutorial for complete beginners that shows you how to make your first iPhone app, from scratch!


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3114-ios-tutorial-how-to-create-a-simple-iphone-app-part-1-3

I followed this tutorial closely, with the only exceptions being that I didn’t prefix my files with RWT, and I am using XCode 7.2. I’ve looked over and over the example code and keep getting an error at this line:
masterController.bugs = bugs;
The stack trace reads as follows:
2016-03-09 08:29:01.206 ScaryBugs[13157:562293] -[UINavigationController setBugs:]: unrecognized selector sent to instance 0x7f80f402b000 2016-03-09 08:29:01.208 ScaryBugs[13157:562293] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController setBugs:]: unrecognized selector sent to instance 0x7f80f402b000' *** First throw call stack: ( 0 CoreFoundation 0x0000000110332e65 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010fda9deb objc_exception_throw + 48 2 CoreFoundation 0x000000011033b48d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x000000011028890a ___forwarding___ + 970 4 CoreFoundation 0x00000001102884b8 _CF_forwarding_prep_0 + 120 5 ScaryBugs 0x000000010f8a2ea2 -[AppDelegate application:didFinishLaunchingWithOptions:] + 1186 6 UIKit 0x00000001106d71f1 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 272 7 UIKit 0x00000001106d8397 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3415 8 UIKit 0x00000001106decc6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1760 9 UIKit 0x00000001106dbe7b -[UIApplication workspaceDidEndTransaction:] + 188 10 FrontBoardServices 0x00000001130e0754 -[FBSSerialQueue _performNext] + 192 11 FrontBoardServices 0x00000001130e0ac2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45 12 CoreFoundation 0x000000011025ea31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 13 CoreFoundation 0x000000011025495c __CFRunLoopDoSources0 + 556 14 CoreFoundation 0x0000000110253e13 __CFRunLoopRun + 867 15 CoreFoundation 0x0000000110253828 CFRunLoopRunSpecific + 488 16 UIKit 0x00000001106db7cd -[UIApplication _run] + 402 17 UIKit 0x00000001106e0610 UIApplicationMain + 171 18 ScaryBugs 0x000000010f8a455f main + 111 19 libdyld.dylib 0x0000000112a8692d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
Any ideas on why this happened and how I can fix it?

try this:

UINavigationController *nav = [splitViewController.viewControllers firstObject];
RWTMasterViewController *masterController = [nav.viewControllers objectAtIndex:0];
masterController.bugs = bugs;

the problem may be that you didn’t get the right view. check your Main.storyboard. in the latest version, the structure of views is quite different with what is shown in this article.

Hello, was wondering if you guys were able to fix this issue? I’m getting an error too. But now when I tried to remove

UINavigationController *navController = (UINavigationController *) self.window.rootViewController;

with

UINavigationController *nav = [splitViewController.viewControllers firstObject];

now I’m getting an error

"Unknown receiver ‘splitViewController’; did you mean ‘UISplitViewController’?

Hello,

I’m getting a different kind of error message when creating the ScaryBugDoc.h file:

//
// ScaryBugDoc.h
// ScaryBugs
//
// Created by Pierre Binon on 2016-11-21.
// Copyright © 2016 Pierre Binon. All rights reserved.
//

#import <Foundation/Foundation.h>

@class ScaryBugData;

@interface ScaryBugDoc : NSObject

@property (strong) ScaryBugData *data;
@property (strong) UIImage *thumbImage;
@property (strong) UIImage *fullImage;

  • (id) initWithTitle: (NSString *) title rating: (float) rating thumbImage: (UIImage *) thumbImage fullImage: (UIImage *) fullImage;

@end

On both lines with the @property for thumbImage and fullImage, it says "Unknown type name ‘UIImage’… I’m using Xcode 8
Any idea as to why it’s doing that?

Thanks for your help!

Pierre

The reason why it says “Unkown type name ‘UIImage’” is because you need to import UIKit in the scarybugdata.h file

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

Hello,

Managed to fix the issue ,below is the change →

UINavigationController *navController = (UINavigationController *) self.window.rootViewController;

with

UINavigationController navController = [[(UISplitViewController)self.window.rootViewController viewControllers] firstObject];

This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]