EXC_CRASH (SIGBART) Crash Report - ios

Hello everyone I deployed an update for my app and few users have complained/bad reviews etc of app shutting down on them.
One user sent me a crash report and I have re-symbolicated it and it has shown the method where it is crashing and the line number.
I have tried many possible solutions but for the life of me I cannot reproduce it on my device.
Could anyone please be kind and let me know what could be the problem in the following code that is crashing the app:
The line no it is crashing is m:555 i.e
NSAttributedString *attributedText = [[NSAttributedString alloc] initWithString:text attributes:#{NSFontAttributeName: font}];
I am not sure what the issue is, I have tried passing #"" empty as content still it doesn't crashes.
-(CGFloat)getCellHeightForContent:(NSString*)content
{
NSString *text = content;
CGFloat width = self.tableview.frame.size.width - 15 - 30 - 15; //tableView width - left border width - accessory indicator - right border width
UIFont *font = [UIFont systemFontOfSize:17];
NSAttributedString *attributedText = [[NSAttributedString alloc] initWithString:text attributes:#{NSFontAttributeName: font}];
CGRect rect = [attributedText boundingRectWithSize:(CGSize){width, CGFLOAT_MAX}
options:NSStringDrawingUsesLineFragmentOrigin
context:nil];
CGSize size = rect.size;
size.height = ceilf(size.height);
size.width = ceilf(size.width);
if ((size.height )+ 5 < 70) {
return 70;
}
return size.height + 15;
}
here is the crash report
Incident Identifier: CAB2B27B-F65F-4F8A-82C6-C1AECD791335
CrashReporter Key: 759ffd08fa781ee7b8ae9515835758c563110d7f
Hardware Model: iPhone5,1
Process: xxxx [9226]
Path: /var/mobile/Applications/AA5E7A52-ED1E-421F-B377-CF32D55E71EA/xxxx.app/xxxx
Identifier: com.xxxx.xxxx
Version: 7.0.1 (7.0.1)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2014-06-18 22:09:44.336 -0400
OS Version: iOS 7.1.1 (11D201)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x2e33bf06 0x2e267000 + 872198
1 libobjc.A.dylib 0x38ad2ce2 0x38acf000 + 15586
2 CoreFoundation 0x2e33be48 0x2e267000 + 872008
3 Foundation 0x2ec72bd0 0x2ec57000 + 113616
4 Foundation 0x2ec72aac 0x2ec57000 + 113324
5 xxxx 0x00073850 -[DetailVC getCellHeightForContent:] (DetailVC.m:555)
6 xxxx 0x000725b4 -[DetailVC tableView:heightForRowAtIndexPath:] (DetailVC.m:382)
7 UIKit 0x30c7b1ae 0x30b60000 + 1159598
8 UIKit 0x30c3fd92 0x30b60000 + 916882
9 UIKit 0x30c41b6c 0x30b60000 + 924524
10 UIKit 0x30c41ac0 0x30b60000 + 924352
11 UIKit 0x30c416ba 0x30b60000 + 923322
12 xxxx 0x00070c4c -[DetailVC viewDidLoad] (DetailVC.m:157)
13 UIKit 0x30b6fa4e 0x30b60000 + 64078
14 UIKit 0x30b6f80c 0x30b60000 + 63500
15 UIKit 0x30cfbc0e 0x30b60000 + 1686542
16 UIKit 0x30c1948a 0x30b60000 + 758922
......
Thank you in advance for your help!!

Since the crash report is not fully symbolicated and the exception reason is not shown in the report, the following is only an assumption:
You are saying line 555 references this code:
NSAttributedString *attributedText = [[NSAttributedString alloc] initWithString:text attributes:#{NSFontAttributeName: font}];
This causing an exception could be because text is nil.
You should really try to get a fully symbolicated crash report. This requires your Mac to have the iOS symbols of iOS 7.1.1 of armv7s or armv7. You get those symbols by connecting an iPhone 5 or iPad 3 with iOS 7.1.1 running to your Mac. If you can't do that, provide the full crash report somewhere and I'll symbolicate it for you this one time.
Even better if you get a crash report that also shows the exception reason, but usually Apple reports do not contain that, so it might be helpful to integrate a 3rd party crash reporting functionality into your app. (Don't ask for recommendations since I am biased and most answers will also be biased, rather test them yourself and choose wisely).

Related

UICollectionView crash on performBatchUpdates

I can't figure out what's the reason of this crash?
Incident Identifier: BF4459C1-B97D-448E-AAE0-4DA6A1E4731C
CrashReporter Key: E725A626-A25C-4923-8383-0BC7ECA7DADE
Hardware Model: iPhone6,1
Process: SampleProject [480]
Path: /var/containers/Bundle/Application/458F9694-4BDA-4207-8C90-C2192520F8E2/SampleProject.app/SampleProject
Identifier: com.mydomain.SampleProject
Version: 1.3.0 (1.3.0.36)
Code Type: ARM-64
Parent Process: ??? [1]
Date/Time: 2017-05-17T04:11:03Z
Launch Time: 2017-05-17T04:06:51Z
OS Version: iPhone OS 10.3.1 (14E304)
Report Version: 104
Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0xfffffffffffffff8
Crashed Thread: 0
Application Specific Information:
Selector name found in current argument registers: _setLayoutAttributes:atGlobalItemIndex:
Thread 0 Crashed:
0 UIKit 0x000000018de7d38c -[UICollectionViewData _setLayoutAttributes:atGlobalItemIndex:] + 80
1 UIKit 0x000000018de7ac94 __45-[UICollectionViewData validateLayoutInRect:]_block_invoke + 1892
2 UIKit 0x000000018de79f68 -[UICollectionViewData validateLayoutInRect:] + 1492
3 UIKit 0x000000018de8023c -[UICollectionViewData layoutAttributesForElementsInRect:] + 264
4 UIKit 0x000000018de7dbc0 -[UICollectionView _updateVisibleCellsNow:] + 548
5 UIKit 0x000000018dfea058 -[UICollectionView _setupCellAnimations] + 28
6 UIKit 0x000000018dff459c -[UICollectionView _beginUpdates] + 44
7 UIKit 0x000000018e72c8c0 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:] + 256
8 UIKit 0x000000018e72c79c -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:] + 92
9 UIKit 0x000000018e72c720 -[UICollectionView _performBatchUpdates:completion:invalidationContext:] + 80
10 UIKit 0x000000018dff4558 -[UICollectionView performBatchUpdates:completion:] + 60
11 SampleProject 0x000000010002a4b8 -[InvitesDataSource didDeleteDataAtIndexes:loadDataAtIndexes:] (InvitesDataSource.m:50)
12 SampleProject 0x0000000100092f58 -[DialogsController _didReceiveOldestInvites:] (DialogsController.m:311)
13 SampleProject 0x0000000100092500 -[DialogsController _didReceiveOldestDialogs:ofType:] (DialogsController.m:248)
14 SampleProject 0x000000010004aad8 -[DialogsController(Notifications) dialogListDidReceived:] (DialogsController+Notifications.m:94)
Piece of code mentioned in crashlog is quite peaceful:
- (void)didDeleteDataAtIndexes:(NSIndexSet *)deleted loadDataAtIndexes:(NSIndexSet *)loaded {
[self.collectionView performBatchUpdates:^{
[deleted enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
[self.collectionView deleteItemsAtIndexPaths:[self _indexPathsForIndex:idx]];
}];
[loaded enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
[self.collectionView insertItemsAtIndexPaths:[self _indexPathsForIndex:idx]];
}];
} completion:^(BOOL finished) {
[self.collectionView reloadData];
}];
}
This may be happening because you do need to also make sure with collectionViews to delete and insert sections. when you try to insert an item in a section that doesn't exist you will get this crash.
Preform Batch updates doesn't know that you meant to add section X+1 when you insert an item at X+1, X. without you already having added that section in.
make sure to use insert and delete section:
https://developer.apple.com/documentation/uikit/uicollectionview/1618090-insertsections
https://developer.apple.com/documentation/uikit/uicollectionview/1618102-deletesections
To insert, delete, or move a single section or item, you must follow these steps:
Update the data in your data source object.
Call the appropriate method of the collection view to insert or delete the section or item.
It is critical that you update your data source before notifying the collection view of any changes. The collection view methods assume that your data source contains the currently correct data. If it does not, the collection view might receive the wrong set of items from your data source or ask for items that are not there and crash your app.

App crashing when launching from AppStore or TestFlight but working fine elseways

My application update has been rejected. Into the rejection message, they wrote "Application crashes at launch". I then tried my application but couldn't make it crash. So I used TestFlight and noticed that when I was launched my app from TestFlight or AppStore, it was crashing at launch. But if I launch my app normally, it does work without any crashes. The thing is this bug occurred since iOS 10 update. Now my application on store also crashes when launched from AppStore while it was working fine 2 weeks go.
Apple sent me a crash log:
Incident Identifier: 001969F1-F275-4AC3-AFE1-E0426957B702
CrashReporter Key: 5ad9695e945a7d5eb5d61fd18d1c3989ccd155b4
Hardware Model: xxx
Process: MyApp [400]
Path: /private/var/containers/Bundle/Application/644423A4-EFE7-41B1-99D9-47B46338A6E2/MyApp.app/MyApp
Identifier: com.MyApp.com
Version: 20160527 (2.7.9)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.MyApp.com [451]
Date/Time: 2016-09-22 11:19:22.6893 -0700
Launch Time: 2016-09-22 11:19:22.4164 -0700
OS Version: iPhone OS 10.0.1 (14A403)
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000010008a864
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [0]
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 MyApp 0x1000efd3c specialized AppDelegate.application(UIApplication, didFinishLaunchingWithOptions : [NSObject : AnyObject]?) -> Bool (AppDelegate.swift:218)
1 MyApp 0x1000ed310 #objc AppDelegate.application(UIApplication, didFinishLaunchingWithOptions : [NSObject : AnyObject]?) -> Bool (AppDelegate.swift)
2 UIKit 0x19888c42c <redacted> + 400
3 UIKit 0x198a9cb70 <redacted> + 3524
4 UIKit 0x198aa28e0 <redacted> + 1656
5 UIKit 0x198ab7080 <redacted> + 48
6 UIKit 0x198a9f8c4 <redacted> + 168
7 FrontBoardServices 0x1945798bc <redacted> + 36
8 FrontBoardServices 0x194579728 <redacted> + 176
9 FrontBoardServices 0x194579ad0 <redacted> + 56
10 CoreFoundation 0x192986278 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
11 CoreFoundation 0x192985bc0 __CFRunLoopDoSources0 + 524
12 CoreFoundation 0x1929837c0 __CFRunLoopRun + 804
13 CoreFoundation 0x1928b2048 CFRunLoopRunSpecific + 444
14 UIKit 0x1988855dc <redacted> + 608
15 UIKit 0x198880360 UIApplicationMain + 208
16 MyApp 0x1000ee818 main (AppDelegate.swift:58)
17 libdispatch.dylib 0x1918945b8 (Missing)
There is 4 others threads but this one is the one crashing so I did not copy the rest. I did some research and even though I did notice my crash log wasn't fully translated (for some strange reason since I have all dsyms but whatever), I did manage to understand that I was crashing on line 217 (tell me if I'm wrong). I know that SIGTRAP are most of time NSExceptions being thrown. The line itself is:
let api = MyAppAPI.instance
The instance is a singleton. My guess is that something into the instance creation is failing. Here is the code:
static var instance: MyAppAPI = {
return Singleton.instance
}()
class MyAppAPI: Manager {
struct Singleton {
static var configuration: NSURLSessionConfiguration = {
var configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
let version = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString") as? String ?? ""
configuration.HTTPAdditionalHeaders = [
"Accept": "application/vnd.MyApp.api+json, application/json;q=0.9",
"User-Agent": "MyApp iOS/\(version)",
"X-API-Version": "1.0.1"
]
return configuration
}()
static var instance = MyAppAPI(configuration: configuration)
static var baseURL : NSURL! = nil
}
I'm so desperate about this error, I did try a few things that did not work out. Am I looking into the right place ? Is there anyone with a solution ? Any kind of help would be greatly appreciated. I'm willing to gift anyone that can find me the solution or help me find the solution !
I found the solution of my problem.
As expected it was coming from func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
Inside the function I had let userInfo = launchOpts[UIApplicationLaunchOptionsRemoteNotificationKey] as! NSDictionary.
I changed it to let userInfo = launchOpts[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary and then checked if userInfo != nil to make all the code running userInfointo the bracket.
If it helps anyone or if anyone is struggling with this issue, check all yours ! and swap these to ? if needed (on didFinishLaunchingWithOptions) since launching from TestFlight/AppStore seems to have different options than from installed application (just a guess, not pro enough to claim it).

Segfault from NSLog?

I'm seeing a segfault from using NSLog and specifically, it is on a 64 bit device, with a SEGV_ACCERR. I'm new to iOS, so i'm a little confused.
Here's the stack trace:
Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0x108074000
Crashed Thread: 0
Thread 0 Crashed:
0 libsystem_platform.dylib 0x00000001826ea31c _platform_memmove + 300
1 libsystem_asl.dylib 0x00000001825289a4 asl_string_append_no_encoding_len + 92
2 libsystem_asl.dylib 0x0000000182522fc8 asl_string_new + 108
3 libsystem_asl.dylib 0x0000000182522df4 asl_msg_to_string_raw + 68
4 libsystem_asl.dylib 0x00000001825228dc _asl_send_message + 828
5 libsystem_asl.dylib 0x00000001825224fc asl_send + 8
6 CoreFoundation 0x0000000182a6fa1c __CFLogCString + 568
7 CoreFoundation 0x0000000182a6f7ac _CFLogvEx2 + 300
8 CoreFoundation 0x0000000182a6fc14 _CFLogvEx3 + 152
9 Foundation 0x0000000183435dd8 _NSLogv + 128
10 Foundation 0x000000018336ae04 NSLog + 28
Here is the code that calls this:
NSString *truncated = [NSString stringWithUTF8String:buffer];
// Using original NSLog to print.
#undef NSLog
NSLog(#"%#", truncated);
and it crashes from my NSLog call.
where buffer is just a char buffer.
My questions specifically are:
Is it even possible to crash from using Apple's provided NSLog? Or is my stack trace wrong?
What does SEG_ACCERR even mean in this context?
How could i go about finding if this was caused by a bad memory issue or not?
Is something blowing up with the asl file under multiple threads?
How should i approach debugging this?
Any help would be greatly appreciated! Thanks!
You say that buffer is a char buffer. If that is the case, you should initialize the string like this
NSString *truncated = [[NSString alloc] initWithBytes:buffer
length:len NSUTF8StringEncoding];
where len is the length of the characters in the buffer.

How to debug EXC_BAD_ACCESS in Apple's Accelerator code?

On sporadic occasions I'm getting an EXC_BAD_ACCESS (SIGSEV) in one of Apple's Accelerator framework methods, vDSP_fft2d_zip. The crash report gave the following for Thread 10. Again, most of the time this works like a champ. Any ideas on how to find the cause and fix it?
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x412f2740
Triggered by Thread: 10
. . .
Thread 10 Crashed:
0 libvDSP.dylib 0x2ddfcdb4 ___lldb_unnamed_function431$$libvDSP.dylib + 68
1 libvDSP.dylib 0x2ddfab66 ___lldb_unnamed_function427$$libvDSP.dylib + 562
2 libvDSP.dylib 0x2ddfa8ee vDSP_fft2d_zop + 434
3 libvDSP.dylib 0x2ddfa732 vDSP_fft2d_zip + 18
4 ASSIST for iPad 0x000ac32e -[Processor setupFilterForBubbleSizeMM:rectWidth:rectImageWidth:dataFilled:dataUnfilled:] (Processor.mm:813)
5 ASSIST for iPad 0x000af4d2 -[Processor runConvolutionProcessOnImage:aveImage:] (Processor.mm:1835)
6 ASSIST for iPad 0x000ac5f6 -[Processor processAnswers] (Processor.mm:869)
7 ASSIST for iPad 0x000ae9cc -[Processor process] (Processor.mm:1644)
8 ASSIST for iPad 0x000d7744 -[ReallTimeScanner processImage:] (ReallTimeScanner.mm:1046)
9 Foundation 0x2f296c82 __NSThread__main__ + 1058
10 libsystem_pthread.dylib 0x396b6c1a _pthread_body + 138
11 libsystem_pthread.dylib 0x396b6b8a _pthread_start + 98
12 libsystem_pthread.dylib 0x396b4c8c thread_start + 4
The relevant code looks like this:
#define FFT_SIZE 512
#define FFT_POWER 9
dataFilledIn->imagp=(float *) malloc(sizeof(float)*FFT_SIZE*FFT_SIZE);
dataFilledIn->realp=(float *) malloc(sizeof(float)*FFT_SIZE*FFT_SIZE);
dataUnfilledIn->imagp=(float *) malloc(sizeof(float)*FFT_SIZE*FFT_SIZE);
dataUnfilledIn->realp=(float *) malloc(sizeof(float)*FFT_SIZE*FFT_SIZE);
memset(dataFilledIn->imagp, 0, sizeof(float)*FFT_SIZE*FFT_SIZE);
memset(dataFilledIn->realp, 0, sizeof(float)*FFT_SIZE*FFT_SIZE);
memset(dataUnfilledIn->imagp, 0, sizeof(float)*FFT_SIZE*FFT_SIZE);
memset(dataUnfilledIn->realp, 0, sizeof(float)*FFT_SIZE*FFT_SIZE);
for(float y=0; y<FFT_SIZE; y+=0.25)
{
for(float x=0; x<FFT_SIZE; x+=0.25)
{
dataFilledIn->realp[(int)y*FFT_SIZE+(int)x] += 0.0625;
dataUnfilledIn->realp[(int)y*FFT_SIZE+(int)x] -= 0.0625;
}
}
vDSP_fft2d_zip(setup, dataFilledIn, 1, 0, FFT_POWER, FFT_POWER, kFFTDirection_Forward);
Answering my own question here: Be sure that the very first parameter sent in (type FFTSetup) to vDSP_fft2d_zip() is initialized correctly, and you should use this call
vDSP_destroy_fftsetup(setup);
to clean it up. I was initializing the setup var properly, like this
setup = vDSP_create_fftsetup(FFT_POWER, kFFTRadix2);
and then cleaning it up, but then was not initializing it again before subsequent calls to vDSP_fft2d_zip(). Unfortunately it only rarely caused a crash, which made it seem like the frequent calls to vDSP_fft2d_zip(setup, . . .) were working when they weren't. The crashes were sporadic making the real cause hard to trace.
There are some articles in Raywenderlich may help you:
Objectively Speaking: A Crash Course in Objective C for iOS 6
Objectively Speaking 2: A Crash Course in Objective C for iOS 6

Xcode 4 and "SIGABRT" error? (only for iphone though)

I'm new to ios development and to stackoverflow. I did try searching both stackoverflow and google before posting.
I built a simple little app, originally just left it an iphone only app, but decided to make it universal in the end. I, stupidly, was messing around when i was getting to know xcode 4 and switched it to universal and then back again so i had to recopy the project and do it again. This time i started it with a universal app. (Not when i created it but after i went to project and selected it there) It created the ipad folder and mainwindow-ipad.xib file but was empty of course since i didn't do anything yet. I had it set up as a tabbed based app so my iphone version had firstview and secondview nib files also, but the ipad version didn't. I set it all up in iphone version first and it worked fine. I then went and laid down the ipad version (i did eliminate the second tab from mainwindow-ipad because i didn't need it)
i then went and created a new nib file and placed it in the ipad folder along with "main-ipad.h" and "main-ipad.m". I copied my code and connected everything and it runs fine on ipad simulator but now when i try and run iphone simulator i get "SIGABRT error. I took a screen shot of it. I don't fully understand objective-c so i was hoping someone can help me? I can post any code or whatever you might need to help me with this error so just ask.
Appreciate any help and suggestions you may have!
Thanks!
[Okay i would have posted image but I can't since I'm a new user, instead i posted the line highlighted and the output from xcode]
Code for file with error:
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil); //ERROR IS ON THIS LINE <-----
[pool release];
return retVal;
}
[OUTPUT]
2011-06-18 17:32:43.980 Price Assist[445:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4e09cc0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key finallabel.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc35a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f17313 objc_exception_throw + 44
2 CoreFoundation 0x00dc34e1 -[NSException raise] + 17
3 Foundation 0x00795677 _NSSetUsingKeyValueSetter + 135
4 Foundation 0x007955e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x0021130c -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x00d398cf -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x0020fd23 -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x00211ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x000c7628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
10 UIKit 0x000c5134 -[UIViewController loadView] + 120
11 UIKit 0x000c500e -[UIViewController view] + 56
12 UIKit 0x00038d42 -[UIWindow addRootViewControllerViewIfPossible] + 51
13 Foundation 0x007955e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
14 UIKit 0x00048ff6 -[UIView(CALayerDelegate) setValue:forKey:] + 173
15 UIKit 0x0021130c -[UIRuntimeOutletConnection connect] + 112
16 CoreFoundation 0x00d398cf -[NSArray makeObjectsPerformSelector:] + 239
17 UIKit 0x0020fd23 -[UINib instantiateWithOwner:options:] + 1041
18 UIKit 0x00211ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
19 UIKit 0x0001717a -[UIApplication _loadMainNibFile] + 172
20 UIKit 0x00017cf4 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
21 UIKit 0x00022617 -[UIApplication handleEvent:withNewEvent:] + 1533
22 UIKit 0x0001aabf -[UIApplication sendEvent:] + 71
23 UIKit 0x0001ff2e _UIApplicationHandleEvent + 7576
24 GraphicsServices 0x00ffc992 PurpleEventCallback + 1550
25 CoreFoundation 0x00da4944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
26 CoreFoundation 0x00d04cf7 __CFRunLoopDoSource1 + 215
27 CoreFoundation 0x00d01f83 __CFRunLoopRun + 979
28 CoreFoundation 0x00d01840 CFRunLoopRunSpecific + 208
29 CoreFoundation 0x00d01761 CFRunLoopRunInMode + 97
30 UIKit 0x000177d2 -[UIApplication _run] + 623
31 UIKit 0x00023c93 UIApplicationMain + 1160
32 Price Assist 0x000029a9 main + 121
33 Price Assist 0x00002925 start + 53
)
terminate called after throwing an instance of 'NSException'
iPhone FirstView nib file .h code:
#interface FirstViewController : UIViewController {
IBOutlet UITextField *dollarinput;
IBOutlet UITextField *centsinput;
IBOutlet UIButton *combinevalue;
IBOutlet UITextField *percentoffinput;
IBOutlet UILabel *discountlabel;
IBOutlet UILabel *finallabel;
}
- (IBAction)calculate:(id)sender;
- (IBAction)backgroundTouched:(id)sender;
- (IBAction)autonext:(id)sender;
iPhone FirstView nib file .m code:
//
// FirstViewController.m
// Price Assist
//
// Created by Dustin Schreiber on 6/15/11.
// Copyright 2011 TheTechSphere.com. All rights reserved.
//
#import "FirstViewController.h"
#implementation FirstViewController
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
}
*/
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren't in use.
}
- (void)viewDidUnload
{
[percentoffinput release];
percentoffinput = nil;
[discountlabel release];
discountlabel = nil;
[finallabel release];
finallabel = nil;
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc
{
[percentoffinput release];
[discountlabel release];
[finallabel release];
[super dealloc];
}
- (IBAction)calculate:(id)sender {
if ([centsinput.text length] == 0){
centsinput.text = #"00";
}
if ([dollarinput.text length] == 0){
dollarinput.text = #"00";
}
if ([percentoffinput.text length] == 0){
percentoffinput.text = #"00";
}
double cDollars = [dollarinput.text doubleValue];
double cCents = [centsinput.text doubleValue];
double percentoff = [percentoffinput.text doubleValue] / 100;
NSString *ccDollars = [[NSNumber numberWithFloat:cDollars] stringValue];
NSString *ccCents = [[NSNumber numberWithFloat:cCents] stringValue];
NSString *placeholder = [NSString stringWithFormat:#"%#.%#", ccDollars, ccCents];
double combined = [placeholder doubleValue];
double discount = combined * percentoff;
NSString *discountholder2 =[NSString stringWithFormat:#"%.2f", discount];
discountlabel.text = discountholder2;
double newprice = (combined - discount);
NSString *str = [NSString stringWithFormat:#"%.2f", newprice];
finallabel.text = str;
dollarinput.text = ccDollars;
centsinput.text = ccCents;
percentoffinput.text = [[NSNumber numberWithFloat:percentoff] stringValue];
}
-(IBAction)backgroundTouched:(id)sender
{
[dollarinput resignFirstResponder];
[centsinput resignFirstResponder];
[percentoffinput resignFirstResponder];
}
- (IBAction)autonext:(id)sender {
if ([centsinput.text length ] >= 2) {
if ([centsinput.text length] > 2) {
centsinput.text = #"";
} else {
//next field
}
}
}
#end
Thanks again! If anyone has any suggestions for my code i'd love to here them! Like I said, I'm new to it and thats the only way i know to do this.
------------> If anyone wants, I'll upload the entire project folder. Just ask. Thank you guys for all the help. i'm a n00b with xcode so i haven't got it all down yet.
Project Zipped
Post some code where you use finallabel and try to debug your app so you can tell me the line just before the app crashes.
Option 2:
Try to set a BreakPoint in malloc_error_break so we can have more info about the error.
In XCode go to Run -> Show -> BreakPoints (or just cmd + option + B). Then double click to add a new symbol (symbolic breakpoint) and type in malloc_error_break then press enter.
Now run your app and paste your console text.
UPDATE If you need help http://developer.apple.com/library/mac/#recipes/xcode_help-breakpoint_navigator/articles/adding_a_symbolic_breakpoint.html
Check your connections inside your InterfaceBuilder, you may have it wrong with fianllabel.
Also check your Custom Class -> Class in your iphone XIB in your InterfaseBuilder
UPDATE
Go to Product -> Clean. Then Run.
The line UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); just means that an exception was thrown during the running of your program. This could range from a memory problem, to a simple runtime error. Look in the target debugger console; it will tell you where the error occurred.
Open "iOS Simulator" Menu in the upper left->Reset Content and Settings. Then quit the iOS simulator and Xcode, and then restart your computer. This will get rid of the other instance of the process.
This May work it's work for me...........
The problem is with your XIB file. This error generally occurs when your finalLabel is incorrectly hooked up or doesn't exist anymore. Check your connections in the Interface Builder once.
I also had this error. After spending so much time, I found how to fix it. First of all go the console and see where is the error (mine was related to storyboards and its code) The way I fixed my error was by going in story board. Below the iPhone screen, there will be small yellow button. Right click on it and you will see that is causing error. Delete(x) it if there is yellow error sign.
If this does not fix your error then try to make new project and then replace its blank files with old files of your old project. I had same error in very beginning and by doing this program run without any error.
Other people suggests by restarting your laptop and running it again, reseting the iOS simulator, or changing iOS debugger (however this does not work in latest x code since there is only one debugger)
Hope this helps

Resources