My app was working fine this morning. I updated to Xcode 5.1 and when I run my app, it crashes when I hit play. My app has a modal button that leads to another view controller. The first view controller is the main screen. I start the app, press the play button, then it does nothing for about a second (instead of taking me to the second view controller, which is the game itself), and then Xcode takes me to the main.m. This is what my main.m looks like (have not modified it). So, when Xcode takes me here, the line that starts with return UIApplicationMain is highlighted in green and on the far right it says thread 1: signal SIGABRT
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
Does anyone have a suggestion about what is going on?
------updated
I am not sure if this helps (because I'm still a beginner, but i think this is it). it says:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter' *** First throw call stack:
(
0 CoreFoundation 0x01f0c1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0180a8e5 objc_exception_throw + 44
2 CoreFoundation 0x01f0bfbb +[NSException raise:format:] + 139
3 Foundation 0x0142692b -[NSURL(NSURL) initFileURLWithPath:] + 123
4 Foundation 0x014267fd +[NSURL(NSURL) fileURLWithPath:] + 67
5 Bad Jetpack Complete 0x00004f92 -[Game viewDidLoad] + 1170
6 UIKit 0x005e933d -[UIViewController loadViewIfRequired] + 696
7 UIKit 0x005e95d9 -[UIViewController view] + 35
8 UIKit 0x005f8f89 -[UIViewController shouldAutorotate] + 36
9 UIKit 0x005f92d1 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 297
10 UIKit 0x008973d5 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 2330
11 UIKit 0x005f55d5 -[UIViewController presentViewController:withTransition:completion:] + 6538
12 UIKit 0x005f5aef -[UIViewController presentViewController:animated:completion:] + 130
13 UIKit 0x005f5b2f -[UIViewController presentModalViewController:animated:] + 56
14 UIKit 0x00a3fe00 -[UIStoryboardModalSegue perform] + 271
15 UIKit 0x00a2ef0c -[UIStoryboardSegueTemplate _perform:] + 174
16 UIKit 0x00a2ef87 -[UIStoryboardSegueTemplate perform:] + 115
17 libobjc.A.dylib 0x0181c880 -[NSObject performSelector:withObject:withObject:] + 77
18 UIKit 0x004cc3b9 -[UIApplication sendAction:to:from:forEvent:] + 108
19 UIKit 0x004cc345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
20 UIKit 0x005cdbd1 -[UIControl sendAction:to:forEvent:] + 66
21 UIKit 0x005cdfc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
22 UIKit 0x005cd243 -[UIControl touchesEnded:withEvent:] + 641
23 UIKit 0x0050bddd -[UIWindow _sendTouchesForEvent:] + 852
24 UIKit 0x0050c9d1 -[UIWindow sendEvent:] + 1117
25 UIKit 0x004de5f2 -[UIApplication sendEvent:] + 242
26 UIKit 0x004c8353 _UIApplicationHandleEventQueue + 11455
27 CoreFoundation 0x01e9577f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
28 CoreFoundation 0x01e9510b __CFRunLoopDoSources0 + 235
29 CoreFoundation 0x01eb21ae __CFRunLoopRun + 910
30 CoreFoundation 0x01eb19d3 CFRunLoopRunSpecific + 467
31 CoreFoundation 0x01eb17eb CFRunLoopRunInMode + 123
32 GraphicsServices 0x030885ee GSEventRunModal + 192
33 GraphicsServices 0x0308842b GSEventRun + 104
34 UIKit 0x004caf9b UIApplicationMain + 1225
35 Bad Jetpack Complete 0x00002e7d main + 141
36 libdyld.dylib 0x03c7f701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
- (void)viewDidLoad
{
CactusTop.hidden = YES;
CactusBottom.hidden = YES;
ScoreLabel.hidden = YES;
GameOverScreen.hidden = YES;
RestartButton.hidden = YES;
LeaderBoardButton.hidden = YES;
ScoreLabel2.hidden = YES;
HighscoreLabel.hidden = YES;
RestartButton.hidden = YES;
HighScoreNumber = [[NSUserDefaults standardUserDefaults] integerForKey:#"HighScoreSaved"];
NSURL *ClickURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"Click"ofType:#"mp3"]];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)ClickURL, & ClickSound);
NSURL *ExplosionURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"Explosion" ofType:#"mp3"]];
ExplosionSound = [[AVAudioPlayer alloc] initWithContentsOfURL:ExplosionURL error:nil];
[ExplosionSound setNumberOfLoops:0];
[ExplosionSound prepareToPlay];
NSURL *JetpackURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"Jetpack 1_2sec_01c" ofType:#"mp3"]];
JetpackSound = [[AVAudioPlayer alloc] initWithContentsOfURL:JetpackURL error:nil];
[JetpackSound setNumberOfLoops:0];
[JetpackSound prepareToPlay];
NSURL *PointURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"Point" ofType:#"mp3"]];
PointSound = [[AVAudioPlayer alloc] initWithContentsOfURL:PointURL error:nil];
[PointSound setNumberOfLoops:0];
[PointSound prepareToPlay];
this is the updated question with the view did load
OK, somewhere in your app you are trying to load a file from a URL but the URL is nil.
Can you show the code where you are doing this. It will help answer you question.
Actually, it's in the file Game.m in the method - (void)viewDidLoad;.
Related
I searched online and GitHub and couldn't find a way to properly select a PDF in IOS like with an image or video. For example, I can open and select a photo (select the photo with other methods that hadle it) like this:
self.logoImagePicker = [[UIImagePickerController alloc] init];
self.logoImagePicker.delegate = self;
[self.logoImagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:self.logoImagePicker animated:YES completion:nil];
I've attempted this:
// Present PDF;s from which to choose
UIDocumentInteractionController *pdfPicker = [[UIDocumentInteractionController alloc] init];
pdfPicker.delegate = self; // ensure you set the delegate so when a PDF is chosen the right method can be called
[self presentViewController:pdfPicker animated:YES completion:nil];
But i get an error here:
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
With this error output:
2016-08-10 07:40:59.190 Whats New[55195:1962738] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'No available types for source 0'
*** First throw call stack:
(
0 CoreFoundation 0x00ef1494 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0060fe02 objc_exception_throw + 50
2 UIKit 0x01eb9dc2 -[UIImagePickerController mediaTypes] + 0
3 Whats New 0x000c6253 -[SellerHomePageViewController choosePdfBtn:] + 243
4 libobjc.A.dylib 0x006240b5 -[NSObject performSelector:withObject:withObject:] + 84
5 UIKit 0x01ab0e38 -[UIApplication sendAction:to:from:forEvent:] + 118
6 UIKit 0x01ab0db7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
7 UIKit 0x01c54f3b -[UIControl sendAction:to:forEvent:] + 79
8 UIKit 0x01c552d4 -[UIControl _sendActionsForEvents:withEvent:] + 433
9 UIKit 0x01c542c1 -[UIControl touchesEnded:withEvent:] + 714
10 UIKit 0x02037d2e _UIGestureRecognizerUpdate + 12763
11 UIKit 0x01b30efd -[UIWindow _sendGesturesForEvent:] + 1559
12 UIKit 0x01b325b6 -[UIWindow sendEvent:] + 1137
13 UIKit 0x01ad3be8 -[UIApplication sendEvent:] + 266
14 UIKit 0x01aa8769 _UIApplicationHandleEventQueue + 7795
15 CoreFoundation 0x00e03e5f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16 CoreFoundation 0x00df9aeb __CFRunLoopDoSources0 + 523
17 CoreFoundation 0x00df8f08 __CFRunLoopRun + 1032
18 CoreFoundation 0x00df8846 CFRunLoopRunSpecific + 470
19 CoreFoundation 0x00df865b CFRunLoopRunInMode + 123
20 GraphicsServices 0x05aa5664 GSEventRunModal + 192
21 GraphicsServices 0x05aa54a1 GSEventRun + 104
22 UIKit 0x01aaeeb9 UIApplicationMain + 160
23 Whats New 0x000d1e4a main + 138
24 libdyld.dylib 0x03cc4a25 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Is there something similar to choosing photos but only for PDF's?
1- There is no native control for like UIImagePicker that lets you pick a PDF.
2- You have no access to PDFs in the iphone since unlike android, there is no Explorer.
If you want to save PDFs you should save them as coreData in your app, and you should make a UITableView or UICOllectionView with a view for each PDF as a PDF Picker. Keep in mind this will stay within the context of the app as IOS behaves differently than android
I have created some simple code designed to show a webpage, which has been working perfectly fine since I created it. However, when I now run the app, the UIWebView no longer displays the webpage, although the NSLog shows the code is definitely being run.
In the .h: #property (weak, nonatomic) IBOutlet UIWebView *webView;
In the .m:
#synthesize webView;
- (void)viewDidLoad {
NSString *url = #"http://www.google.com";
[self createWebpage:url];
self.addressBar.delegate = self;
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void) createWebpage:(NSString *)webString {
NSURL *url = [NSURL URLWithString:webString];
NSURLRequest *requestUrl = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:requestUrl];
NSLog(#"Webpage is created!");
}
I recently (accidentally) deleted a Referencing Outlet between the back and forward UIButtons I had created. I say this in case it has anything to do with the problem. All help appreciated.
EDIT: I don't know why, but the app now does not load. It goes to the splash screen, and then errors, producing the error log below.
2014-09-21 14:19:14.273 Fullscreen Ninja Browser for iPhone 6[6673:349224] Webpage is created!
2014-09-21 14:19:14.278 Fullscreen Ninja Browser for iPhone 6[6673:349224] *** Assertion failure in -[NSLayoutConstraint constant], /SourceCache/Foundation_Sim/Foundation-1140.11/Layout.subproj/NSLayoutConstraint.m:643
2014-09-21 14:19:14.283 Fullscreen Ninja Browser for iPhone 6[6673:349224] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '(null)'
*** First throw call stack:
(
0 CoreFoundation 0x0000000105a073f5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001056a0bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000105a0725a +[NSException raise:format:arguments:] + 106
3 Foundation 0x00000001052be28f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 Foundation 0x000000010523a18d -[NSLayoutConstraint constant] + 170
5 Foundation 0x0000000105243ea3 -[NSLayoutConstraint _lowerIntoExpression:reportingConstantIsRounded:] + 197
6 Foundation 0x0000000105239dbe -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 96
7 UIKit 0x0000000106474495 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 474
8 Foundation 0x0000000105247a8e -[NSISEngine withBehaviors:performModifications:] + 155
9 UIKit 0x000000010647429b __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 452
10 UIKit 0x00000001064740ae -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
11 UIKit 0x0000000106473d21 -[UIView(AdditionalLayoutSupport) _initializeHostedLayoutEngine] + 404
12 UIKit 0x0000000106468caf -[UIView(UIConstraintBasedLayout) _layoutEngine_windowDidChange] + 127
13 UIKit 0x0000000105e66d85 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 207
14 UIKit 0x0000000105e5f9c2 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 125
15 UIKit 0x0000000105e5f936 -[UIView(Hierarchy) _postMovedFromSuperview:] + 437
16 UIKit 0x0000000105e69835 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1550
17 UIKit 0x0000000105e37f43 -[UIWindow addRootViewControllerViewIfPossible] + 452
18 UIKit 0x0000000105e38152 -[UIWindow _setHidden:forced:] + 276
19 UIKit 0x0000000105e4465c -[UIWindow makeKeyAndVisible] + 42
20 UIKit 0x0000000105def191 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2628
21 UIKit 0x0000000105df1e5c -[UIApplication _runWithMainScene:transitionContext:completion:] + 1350
22 UIKit 0x0000000105df0d22 -[UIApplication workspaceDidEndTransaction:] + 179
23 FrontBoardServices 0x00000001085a92a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
24 CoreFoundation 0x000000010593cabc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
25 CoreFoundation 0x0000000105932805 __CFRunLoopDoBlocks + 341
26 CoreFoundation 0x00000001059325c5 __CFRunLoopRun + 2389
27 CoreFoundation 0x0000000105931a06 CFRunLoopRunSpecific + 470
28 UIKit 0x0000000105df0799 -[UIApplication _run] + 413
29 UIKit 0x0000000105df3550 UIApplicationMain + 1282
30 Fullscreen Ninja Browser for iPhone 6 0x00000001051723c3 main + 115
31 libdyld.dylib 0x0000000107f7f145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Edit 2: I have discovered that when I "Add missing constraints" to my UIButton, the above error is caused. However, when I clear the constraints, the app runs fine, with the UIWebView showing the site. However, the buttons are out of place, as adding constraints causes the app to crash, annoyingly. Any solutions?
You need to call [super viewDidLoad], before loading your webView,
This should help to resolve your issue,
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *url = #"http://www.google.com";
[self createWebpage:url];
self.addressBar.delegate = self;
}
I am trying to make my first Objective-C library. I am creating a method which will take in a UIImage and return NSMutableData. I have created the following:
+ (NSMutableData *)GetDataToSendToPrinter:(UIImage *)image
{
int maxWidth = 100;
BOOL drawerKick = YES;
BOOL compressionEnable = YES;
RasterDocument *rasterDoc = [[RasterDocument alloc] initWithDefaults:RasSpeed_Medium endOfPageBehaviour:RasPageEndMode_FeedAndFullCut endOfDocumentBahaviour:RasPageEndMode_FeedAndFullCut topMargin:RasTopMargin_Standard pageLength:0 leftMargin:0 rightMargin:0];
StarBitmap *starbitmap = [[StarBitmap alloc] initWithUIImage:image :maxWidth :false];
NSMutableData *commandsToPrint = [[NSMutableData alloc] init];
NSData *shortcommand = [rasterDoc BeginDocumentCommandData];
[commandsToPrint appendData:shortcommand];
shortcommand = [starbitmap getImageDataForPrinting:compressionEnable];
[commandsToPrint appendData:shortcommand];
shortcommand = [rasterDoc EndDocumentCommandData];
[commandsToPrint appendData:shortcommand];
if (drawerKick == YES) {
[commandsToPrint appendBytes:"\x07"
length:sizeof("\x07") - 1]; // KickCashDrawer
}
[starbitmap release];
[rasterDoc release];
return commandsToPrint;
}
Just for testing purposes, I am trying to call it from a button click event:
- (IBAction)DevButton_TouchUpInside:(id)sender {
UIImage *imageToPrint = [UIImage imageNamed:#"image1.png"];
// NSMutableData *commandsToPrint = [[NSMutableData alloc] init];
// *commandsToPrint=[self GetDataToSendToPrinter:imageToPrint];
//This is where I call it
NSMutableData *commandsToPrint = [self GetDataToSendToPrinter:imageToPrint];
int commandSize = (int)[commandsToPrint length];
unsigned char *dataToSentToPrinter = (unsigned char *)malloc(commandSize);
[commandsToPrint getBytes:dataToSentToPrinter];
NSString *portName = #"TCP:10.0.1.4";
NSString *portSettings = #"Standard";
NSMutableString *message;
SMPort *starPort = nil;
starPort = [SMPort getPort:portName :portSettings :10000];
[starPort writePort:dataToSentToPrinter :0 :commandSize];
}
However I keep getting the following crash when clicking on the button:
Warning: Error creating LLDB target at path '/Users/.../Library/Developer/Xcode/DerivedData/IOS_SDK-cjctcqoxudpegpadjbwitveqtkso/Build/Products/Debug-iphonesimulator/StarIO SDK.app'- using an empty LLDB target which can cause slow memory reads from remote devices.
2014-09-26 18:39:22.588 StarIO SDK[17823:513276] -[IOS_SDKViewControllerRasterMode GetDataToSendToPrinter:]: unrecognized selector sent to instance 0xb366260
2014-09-26 18:39:22.624 StarIO SDK[17823:513276] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[IOS_SDKViewControllerRasterMode GetDataToSendToPrinter:]: unrecognized selector sent to instance 0xb366260'
*** First throw call stack:
(
0 CoreFoundation 0x021c4df6 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x01c49a97 objc_exception_throw + 44
2 CoreFoundation 0x021cca75 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x021159c7 ___forwarding___ + 1047
4 CoreFoundation 0x0211558e _CF_forwarding_prep_0 + 14
5 StarIO SDK 0x000428bb -[IOS_SDKViewControllerRasterMode DevButton_TouchUpInside:] + 107
6 libobjc.A.dylib 0x01c5f7cd -[NSObject performSelector:withObject:withObject:] + 84
7 UIKit 0x0042179d -[UIApplication sendAction:to:from:forEvent:] + 99
8 UIKit 0x0042172f -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
9 UIKit 0x00554a16 -[UIControl sendAction:to:forEvent:] + 69
10 UIKit 0x00554e33 -[UIControl _sendActionsForEvents:withEvent:] + 598
11 UIKit 0x0055409d -[UIControl touchesEnded:withEvent:] + 660
12 UIKit 0x00471aba -[UIWindow _sendTouchesForEvent:] + 874
13 UIKit 0x00472595 -[UIWindow sendEvent:] + 791
14 UIKit 0x00437aa9 -[UIApplication sendEvent:] + 242
15 UIKit 0x004478de _UIApplicationHandleEventFromQueueEvent + 20690
16 UIKit 0x0041c079 _UIApplicationHandleEventQueue + 2206
17 CoreFoundation 0x020e87bf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
18 CoreFoundation 0x020de2cd __CFRunLoopDoSources0 + 253
19 CoreFoundation 0x020dd828 __CFRunLoopRun + 952
20 CoreFoundation 0x020dd1ab CFRunLoopRunSpecific + 443
21 CoreFoundation 0x020dcfdb CFRunLoopRunInMode + 123
22 GraphicsServices 0x03b8c24f GSEventRunModal + 192
23 GraphicsServices 0x03b8c08c GSEventRun + 104
24 UIKit 0x0041fe16 UIApplicationMain + 1526
25 StarIO SDK 0x000027e2 main + 130
26 libdyld.dylib 0x036f0ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I asume I am missing something really basic. It's the first Objective-C method I have created, I'm just looking at building a simple library I can then wrap in a Xamarin binding. Where am I going wrong?
You're calling a class method from an instance method.
+ (NSMutableData *)GetDataToSendToPrinter:(UIImage *)image //Should be called using the class name
- (IBAction)DevButton_TouchUpInside:(id)sender //Should be called using self
I'm not sure how that compiled actually, you should've gotten an error like this:
No visible #interface for IOS_SDKViewControllerRasterMode declares the selector 'GetDataToSendToPrinter:'
Per the log it spit out, it's not finding the function GetDataToSendToPrinter:. Try calling it as a class method:
NSMutableData *commandsToPrint = [IOS_SDKViewControllerRasterMode GetDataToSendToPrinter:imageToPrint];
This question already has answers here:
setValue:forUndefinedKey: this class is not key value coding-compliant for the key [duplicate]
(20 answers)
Closed 8 years ago.
I'm receiving an error while running my xcode project. My app always work, so I can't really see why this isn't working any more. Does anyone have an idea? I've found that it's caused due to an invalid method I'm calling. I can't seem to figure out where this mistake is located.. Anyone?
The error I get:
2014-02-25 11:52:06.784 Chemie Xpert - PSE[1381:70b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x8d49be0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
*** First throw call stack:
(
0 CoreFoundation 0x023625e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bc8b6 objc_exception_throw + 44
2 CoreFoundation 0x023f26a1 -[NSException raise] + 17
3 Foundation 0x00f709ee -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x00edccfb _NSSetUsingKeyValueSetter + 88
5 Foundation 0x00edc253 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6 Foundation 0x00f3e70a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
7 UIKit 0x002bfa15 -[UIRuntimeOutletConnection connect] + 106
8 libobjc.A.dylib 0x014ce7d2 -[NSObject performSelector:] + 62
9 CoreFoundation 0x0235db6a -[NSArray makeObjectsPerformSelector:] + 314
10 UIKit 0x002be56e -[UINib instantiateWithOwner:options:] + 1417
11 UIKit 0x002c02fb -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 165
12 UIKit 0x0001d3bb -[UIApplication _loadMainNibFileNamed:bundle:] + 58
13 UIKit 0x0001d6e9 -[UIApplication _loadMainInterfaceFile] + 245
14 UIKit 0x0001c28f -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 543
15 UIKit 0x0003087c -[UIApplication handleEvent:withNewEvent:] + 3447
16 UIKit 0x00030de9 -[UIApplication sendEvent:] + 85
17 UIKit 0x0001e025 _UIApplicationHandleEvent + 736
18 GraphicsServices 0x022c02f6 _PurpleEventCallback + 776
19 GraphicsServices 0x022bfe01 PurpleEventCallback + 46
20 CoreFoundation 0x022ddd65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
21 CoreFoundation 0x022dda9b __CFRunLoopDoSource1 + 523
22 CoreFoundation 0x0230877c __CFRunLoopRun + 2156
23 CoreFoundation 0x02307ac3 CFRunLoopRunSpecific + 467
24 CoreFoundation 0x023078db CFRunLoopRunInMode + 123
25 UIKit 0x0001badd -[UIApplication _run] + 840
26 UIKit 0x0001dd3b UIApplicationMain + 1225
27 Chemie Xpert - PSE 0x0000247d main + 141
28 libdyld.dylib 0x0598d70d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
My code:
main.m:
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
ViewController.m:
#import "ViewController.h"
#interface ViewController ()
#end
#implementation ViewController
#synthesize webview;
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:#"index" ofType:#"html" inDirectory:#"localHTML"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webview loadRequest:request];
webview.scalesPageToFit = YES;
webview.scrollView.bounces = NO;
webview.scrollView.minimumZoomScale = 1;
webview.scrollView.bouncesZoom = FALSE;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)prefersStatusBarHidden
{
return YES;
}
#end
Maybe you deleted the UIView object from the NIB and replaced with the UIWebView.
This is fine, but you should link the webView to the "view" property of the viewController in the xib file.
Is the webview set as an IBOutlet? That could be the cause.
I need to add an empty object to index 0 and index 1 of an array being populated with data from a third party XML feed.
This is my parseXML method, it works.
-(void) parseXML{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:#"APIKEYHERECANTSHOW YOU"]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *xmlString = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
NSLog(#"The string : %#", xmlString);
NSDictionary *xml = [NSDictionary dictionaryWithXMLString:xmlString];
NSLog(#"The dict:%#", xml);
NSMutableDictionary *PageItem = [xml objectForKey:#"TeamLeagueStanding"];
NSLog(#"PageItem: %#", PageItem);
NSMutableArray *items = [xml objectForKey:#"TeamLeagueStanding"];
NSNull *nullValue = [NSNull null];
[items insertObject:nullValue atIndex:0]; <- THIS MAKES MY APP CRASH
NSLog(#"The array: %#", items);
[self setTableData:items];
}
But when i run this i get a crash with the console output:
2014-02-03 21:24:09.063 Liga Zon Sagres Companion[9645:70b] -[NSNull objectForKey:]: unrecognized selector sent to instance 0x101a85b40
2014-02-03 21:24:09.066 Liga Zon Sagres Companion[9645:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull objectForKey:]: unrecognized selector sent to instance 0x101a85b40'
*** First throw call stack:
(
0 CoreFoundation 0x000000010192a795 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010168d991 objc_exception_throw + 43
2 CoreFoundation 0x00000001019bbbad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010191c09d ___forwarding___ + 973
4 CoreFoundation 0x000000010191bc48 _CF_forwarding_prep_0 + 120
5 Liga Zon Sagres Companion 0x000000010000ee20 -[StandingsTableViewController tableView:cellForRowAtIndexPath:] + 256
6 UIKit 0x00000001003bbb8a -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 348
7 UIKit 0x00000001003a3836 -[UITableView _updateVisibleCellsNow:] + 2297
8 UIKit 0x00000001003b4381 -[UITableView layoutSubviews] + 207
9 UIKit 0x000000010034bb27 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 354
10 QuartzCore 0x0000000102081a22 -[CALayer layoutSublayers] + 151
11 QuartzCore 0x0000000102076589 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 363
12 QuartzCore 0x0000000102081956 -[CALayer layoutIfNeeded] + 162
13 UIKit 0x00000001003ebfc2 -[UIViewController window:setupWithInterfaceOrientation:] + 264
14 UIKit 0x000000010032ab4d -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 4360
15 UIKit 0x0000000100329a3f -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 36
16 UIKit 0x000000010032998f -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 101
17 UIKit 0x0000000100328c9e -[UIWindow _updateToInterfaceOrientation:duration:force:] + 377
18 UIKit 0x00000001003dfd4a -[UIViewController _tryBecomeRootViewControllerInWindow:] + 147
19 UIKit 0x0000000100323a87 -[UIWindow addRootViewControllerViewIfPossible] + 506
20 UIKit 0x0000000100323bd5 -[UIWindow _setHidden:forced:] + 275
21 UIKit 0x000000010032cca2 -[UIWindow makeKeyAndVisible] + 51
22 UIKit 0x00000001002eb0c8 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1449
23 UIKit 0x00000001002eebe8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 660
24 UIKit 0x00000001002ffaab -[UIApplication handleEvent:withNewEvent:] + 3092
25 UIKit 0x00000001002fff1e -[UIApplication sendEvent:] + 79
26 UIKit 0x00000001002f02be _UIApplicationHandleEvent + 618
27 GraphicsServices 0x0000000102578bb6 _PurpleEventCallback + 762
28 GraphicsServices 0x000000010257867d PurpleEventCallback + 35
29 CoreFoundation 0x00000001018ac819 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
30 CoreFoundation 0x00000001018ac5ee __CFRunLoopDoSource1 + 478
31 CoreFoundation 0x00000001018d5ab3 __CFRunLoopRun + 1939
32 CoreFoundation 0x00000001018d4f33 CFRunLoopRunSpecific + 467
33 UIKit 0x00000001002ee4bd -[UIApplication _run] + 609
34 UIKit 0x00000001002f0043 UIApplicationMain + 1010
35 Liga Zon Sagres Companion 0x0000000100011f93 main + 115
36 libdyld.dylib 0x0000000102f815fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Any ideas how to solve this? Thank you.
The error is coming from your StandingsTableViewController tableView:cellForRowAtIndexPath: method. Your data is giving you an NSNull instance where you expect an NSDictionary.
Since you explicitly add the NSNull object you need to update your cellForRow... method to check to see if the object is an NSNull instance before assuming it is an NSDictionary.
Something like this:
NSDictionary *data = self.tableData[someIndex];
if ([data isKindOfClass:[NSDictionary class]]) {
// process the data as usual
} else {
// This is probably the NSNull object, ignore it or handle appropriately
}