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

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

Related

Crashlytics Crash with NSOperationQueue (QOS: UNSPECIFIED)

I'm getting a crash, reported in Crashlytics, and I have no idea how to reproduce the error, It happens randomly so it's hard to debug it with Xcode. Any ideas?
Crashed: NSOperationQueue 0x280419200 (QOS: UNSPECIFIED)
0 libobjc.A.dylib 0x22c471430 objc_retain + 16
1 CoreFoundation 0x22d2b5888 __CFBasicHashAddValue + 1480
2 CoreFoundation 0x22d1e64ac CFDictionarySetValue + 260
3 Foundation 0x22dd04888 _encodeObject + 732
4 myAPI 0x1062b44b0 -[DataCore encodeWithCoder:] (DataCore.m:236)
5 myAPI 0x1062909c4 -[DataHandle encodeWithCoder:] (DataHandle.m:53)
6 Foundation 0x22dd04aa8 _encodeObject + 1276
7 Foundation 0x22dc69c6c +[NSKeyedArchiver archivedDataWithRootObject:] + 168
8 myAPI 0x106288a34 __77+[CachableObject addObjectToCache:withCacheName:withTTL:withCompletionBlock:]_block_invoke (CachableObject.m:162)
9 Foundation 0x22dd198bc NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK + 16
10 Foundation 0x22dc21ab8 -[NSBlockOperation main] + 72
11 Foundation 0x22dc20f8c -[__NSOperationInternal _start:] + 740
12 Foundation 0x22dd1b790 __NSOQSchedule_f + 272
13 libdispatch.dylib 0x22ccc16c8 _dispatch_call_block_and_release + 24
14 libdispatch.dylib 0x22ccc2484 _dispatch_client_callout + 16
15 libdispatch.dylib 0x22cc6582c _dispatch_continuation_pop$VARIANT$mp + 412
16 libdispatch.dylib 0x22cc64ef4 _dispatch_async_redirect_invoke + 600
17 libdispatch.dylib 0x22cc71a18 _dispatch_root_queue_drain + 376
18 libdispatch.dylib 0x22cc722c0 _dispatch_worker_thread2 + 128
19 libsystem_pthread.dylib 0x22cea517c _pthread_wqthread + 472
20 libsystem_pthread.dylib 0x22cea7cec start_wqthread + 4
Here is what the code in DataCore.m looks like
- (void)encodeWithCoder:(NSCoder *)coder {
[super encodeWithCoder:coder];
[coder encodeObject:programFormatPlayInfo forKey:#"ProgramFormatPlayInfo"];
[coder encodeObject:bigScreenPlayInfo forKey:#"BigScreenPlayInfo"];
[coder encodeObject:pivotHandle forKey:#"PivotHandle"];
[coder encodeInteger:pivotDataLinkId forKey:#"PivotDataLinkId"];
[coder encodeInteger:viewContextId forKey:#"ViewContextId"];
[coder encodeBool:suppressImagePivot forKey:#"SuppressImagePivot"];
[coder encodeObject:attributeIds forKey:#"AttributeIds"];
[coder encodeObject:self.overflow forKey:#"Overflow"];
[coder encodeObject:self.cacheNameWithUser forKey:#"CacheNameWithUser"];
[coder encodeObject:self.metaData forKey:#"Metadata"];
}
and here is where I try to add an object to the cache,
not sure if it's failing to decode or something related to the background queue.
+ (void)addObjectToCache:(CachableObject*)object withCacheName:(NSString*)cacheName withTTL:(CacheTime)cacheTimeSeconds withCompletionBlock:(void(^)()) block {
CachableObject* theObject = object;
[_backgroundQueue addOperationWithBlock:^{
#autoreleasepool {
#try {
NSString * path = [CachableObject pathForCachedObject:cacheName];
NSDate * date = [NSDate date];
[object setCacheDate:date];
[object setTtlSeconds:[NSNumber numberWithInteger:cacheTimeSeconds]];
[object setApiVersion:APIVERSION];
// Add to NSCache
[[CachableObject objectCache] setObject:theObject forKey:cacheName];
// Add to file system
NSError* err = nil;
NSData * data = [NSKeyedArchiver archivedDataWithRootObject:theObject];
if (data) {
[data writeToFile:path options:NSDataWritingAtomic error:&err];
}
// Add to dynamic cache
unwrapObjectAndComplyWithClass(object, [DataHandle class], ^(id unwrappedObject) {
DataHandle *objectUnwrapped = unwrappedObject;
DataFrame *objectFrame = objectUnwrapped.frame;
for (NSString *eachDependencyName in objectFrame.dependencies) {
[[VVIDynamicCacheManager sharedManager]addDependencyToStore:eachDependencyName withCacheName:cacheName];
}
}, ^{
/*Not a data handle*/
});
} #catch (NSException* ex) {
NSLog(#"CachableObject: got an exception %#", ex);
} #finally {
if (block) {
block();
}
}
}
}];
}
Some thoughts here.
First, you're using #try/#catch. I believe that NSKeyedArchiver throws exceptions when it should actually return NSError objects. So, perhaps that's why you are doing it. But, you have to keep in mind that none of Apple's frameworks are guaranteed to be exception-safe. This means that catching exceptions can leave Apple's code (and, of course, your own) in inconsistent states that will prevent it from working correctly in the future.
I would strongly recommend either removing the #catch, or scoping it extremely tightly around the NSKeyedArchiver code, if that's why you are using it. This could be unintentionally introducing a variety of other bugs into your app.
Now, on to the specific crash. It's occurring in the runtime's memory management code. This points very strongly at heap corruption. This means you've got a pointer that doesn't point to a valid Objective-C object in memory. This can happen for many reasons, and is extremely common. The most common cause is known as a dangling pointer. However, it could also be caused by an over-release. And, I wouldn't be at all surprised if it is possible to use an #catch to trigger an over-release. (I know, I'm harping, but I've seen so many issues caused by this pattern)
What I generally recommend in these situations:
Look for other crashes that look heap-corruption-related
Try out Zombies in Instruments
Try malloc scribble, or guardmalloc, two other good memory debugging tools
It's hard, and often even impossible, to reason about heap corruption. Replicating the bug can also be impossible, as memory corruption is typically not deterministic.
So, just try to find and fix as many issues as you can. It's totally possible that one of them is responsible for a variety of crashes, one of which could be this one.

Unable to Show onComingCall ViewController for my iOS VoIP Application

I want my App to show IncomingCall ViewController, when App Receives Some Incoming Call.
This is my Code that I uses to show Incoming Call.. From my ContactsViewController, which is Active View when Incoming Call take places.
- (void)showIncomigCallVC{
[self performSegueWithIdentifier:#"segueToIncomingCallVC" sender:nil];
}
This is my Code, that is called by Library.
/* Callback called by the library upon receiving incoming call */
static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id,
pjsip_rx_data *rdata)
{
pjsua_call_info ci;
PJ_UNUSED_ARG(acc_id);
PJ_UNUSED_ARG(rdata);
pjsua_call_get_info(call_id, &ci);
PJ_LOG(3,(THIS_FILE, "....\n\n\n Incoming call from %.*s!! \n\n\n",
(int)ci.remote_info.slen,
ci.remote_info.ptr));
ContactsViewController *incomingCallVC = [[ContactsViewController alloc]init];
[incomingCallVC showIncomigCallVC];
/* Automatically answer incoming calls with 200/OK */
pjsua_call_answer(call_id, 200, NULL, NULL);
}
And This is my Console Output:
20:39:37.482 XCPjsua.c ......
Incoming call from <sip:eeshaMiss12#ekiga.net>!!
2017-01-16 20:39:37.494 simpleVoIP[922:19652] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<ContactsViewController: 0x7bea3d00>) has no segue with identifier 'segueToIncomingCallVC''
*** First throw call stack:
(
0 CoreFoundation 0x03a14212 __exceptionPreprocess + 194
1 libobjc.A.dylib 0x034d3e66 objc_exception_throw + 52
2 UIKit 0x01a69893 -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0
3 simpleVoIP 0x00089ba6 -[ContactsViewController showIncomigCallVC] + 70
4 simpleVoIP 0x00086caf on_incoming_call + 255
5 simpleVoIP 0x000fc273 pjsua_call_on_incoming + 3811
6 simpleVoIP 0x00103294 mod_pjsua_on_rx_request + 84
7 simpleVoIP 0x0012938f pjsip_endpt_process_rx_data + 351
8 simpleVoIP 0x00128bf2 endpt_on_rx_msg + 546
9 simpleVoIP 0x0012fba1 pjsip_tpmgr_receive_packet + 849
10 simpleVoIP 0x001315ec udp_on_read_complete + 316
11 simpleVoIP 0x0014b8e0 ioqueue_dispatch_read_event + 704
12 simpleVoIP 0x0014d5b2 pj_ioqueue_poll + 946
13 simpleVoIP 0x001290c3 pjsip_endpt_handle_events2 + 163
14 simpleVoIP 0x00102023 worker_thread + 99
15 simpleVoIP 0x0014eb96 thread_main + 86
16 libsystem_pthread.dylib 0x04c8a11b _pthread_body + 184
17 libsystem_pthread.dylib 0x04c8a063 _pthread_body + 0
18 libsystem_pthread.dylib 0x04c8993e thread_start + 34
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I am Beginner, any Recommendation will be appreciated.. Thanks in Advance
You are experiencing the crash, because you are programatically allocating your ContactsViewController, instead of using from the storyboard.
When you do this:
ContactsViewController *incomingCallVC = [[ContactsViewController alloc]init];
[incomingCallVC showIncomigCallVC];
You are creating an instance of ContactsViewController, what has nothing to do with the one created in our storyboard.
It would be possible to overcome on this, however, you are trying to make a segue call on a viewController, what has only been loaded to the memory, but is not visible at all. That will never work, it will always crash.
I would recommend to show your viewController, whatever is behind the segue, straight away, instead of creating a viewController and show it with a segue.
EDIT:
Using the code below, you should be able to present your desired UIViewController subclass from the end of your callback function.
// Lets get keywindow
UIWindow* keyWindow = [[[UIApplication sharedApplication] delegate] window];
keyWindow.frame = [UIScreen mainScreen].bounds;
// Lets get `IncomingCallViewController` from storyboard
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"TheNameOfYourStoryboard" bundle:nil];
// do not forget to set the identifier of your viewController on the storyboard as "IncomingCallViewController"
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:#"IncomingCallViewController"];
// Lets present the keyWindow from the main thread
dispatch_async(dispatch_get_main_queue(), ^{
keyWindow.rootViewController = vc;
[keyWindow makeKeyAndVisible];
});

iOS 8.1 with ZXING error ARC forbids explicit message send of 'autorelease'

I developed a DataMatrix Reader for Android with ZXING, and works fine, now I'm working in the version of iOS, but I have this errors when I want to use the library inside my project:
iOS SDK 8.1 and Library
ZXING: https://github.com/TheLevelUp/ZXingObjC
I use the COCOAPODS:
platform :ios, '7.0'
pod 'ZXingObjC', '~> 3.0'
I implemented the library in my project with Cocoapods, now I want to use in my App like this:
#import "ViewController.h"
#import "ZXingObjC.h"
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)scanBarcode:(id)sender {
CGImageRef imageToDecode; // Given a CGImage in which we are looking for barcodes
ZXLuminanceSource *source = [[[ZXCGImageLuminanceSource alloc] initWithCGImage:imageToDecode] autorelease];
ZXBinaryBitmap *bitmap = [ZXBinaryBitmap binaryBitmapWithBinarizer:[ZXHybridBinarizer binarizerWithSource:source]];
NSError *error = nil;
// There are a number of hints we can give to the reader, including
// possible formats, allowed lengths, and the string encoding.
ZXDecodeHints *hints = [ZXDecodeHints hints];
ZXMultiFormatReader *reader = [ZXMultiFormatReader reader];
ZXResult *result = [reader decode:bitmap
hints:hints
error:&error];
if (result) {
// The coded result as a string. The raw data can be accessed with
// result.rawBytes and result.length.
NSString *contents = result.text;
// The barcode format, such as a QR code or UPC-A
ZXBarcodeFormat format = result.barcodeFormat;
} else {
// Use error to determine why we didn't get a result, such as a barcode
// not being found, an invalid checksum, or a format inconsistency.
}
}
#end
but I have this error:
DataMatrixReader/ViewController.m:32:99: ARC forbids explicit message
send of 'autorelease'
DataMatrixReader/ViewController.m:32:99: 'autorelease' is unavailable:
not available in automatic reference counting mode
concretly in this line:
ZXLuminanceSource *source = [[[ZXCGImageLuminanceSource alloc]
initWithCGImage:imageToDecode] autorelease];
Help from "iamnichols"...and after the change the line:
ZXLuminanceSource *source = [[[ZXCGImageLuminanceSource alloc]
initWithCGImage:imageToDecode] autorelease];
to
ZXLuminanceSource *source = [[ZXCGImageLuminanceSource alloc]
initWithCGImage:imageToDecode];
Error:
: CGBitmapContextGetData: invalid context 0x0. This is a
serious error. This application, or a library it uses, is using an
invalid context and is thereby contributing to an overall degradation
of system stability and reliability. This notice is a courtesy: please
fix this problem. It will become a fatal error in an upcoming update.
2014-12-15 12:12:36.122 DataMatrixReader[18838:412778] * Terminating
app due to uncaught exception 'NSInvalidArgumentException', reason:
'Both dimensions must be greater than 0'
* First throw call stack: ( 0 CoreFoundation 0x0000000102626f35 exceptionPreprocess + 165 1 libobjc.A.dylib
0x00000001022bfbb7 objc_exception_throw + 45 2 DataMatrixReader
0x0000000100f09507 -[ZXBitMatrix initWithWidth:height:] + 231 3
DataMatrixReader 0x0000000100f51b7d
-[ZXGlobalHistogramBinarizer blackMatrixWithError:] + 141 4 DataMatrixReader 0x0000000100f530b0
-[ZXHybridBinarizer blackMatrixWithError:] + 816 5 DataMatrixReader 0x0000000100f068ab -[ZXBinaryBitmap blackMatrixWithError:] + 139 6
DataMatrixReader 0x0000000100fa43b2
-[ZXQRCodeReader decode:hints:error:] + 130 7 DataMatrixReader 0x0000000100f63d04 -[ZXMultiFormatReader decodeInternal:error:] + 548
8 DataMatrixReader 0x0000000100f62ade
-[ZXMultiFormatReader decode:hints:error:] + 142 9 DataMatrixReader 0x0000000100ef1df2 -[ViewController scanBarcode:] + 322 10 UIKit
0x0000000102a148be -[UIApplication sendAction:to:from:forEvent:] + 75
11 UIKit 0x0000000102b1b410
-[UIControl _sendActionsForEvents:withEvent:] + 467 12 UIKit 0x0000000102b1a7df -[UIControl touchesEnded:withEvent:] + 522 13
UIKit 0x0000000102a5a308 -[UIWindow
_sendTouchesForEvent:] + 735 14 UIKit 0x0000000102a5ac33 -[UIWindow sendEvent:] + 683 15 UIKit
0x0000000102a279b1 -[UIApplication sendEvent:] + 246 16 UIKit
0x0000000102a34a7d _UIApplicationHandleEventFromQueueEvent + 17370 17
UIKit 0x0000000102a10103
_UIApplicationHandleEventQueue + 1961 18 CoreFoundation 0x000000010255c551
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 19 CoreFoundation 0x000000010255241d
__CFRunLoopDoSources0 + 269 20 CoreFoundation 0x0000000102551a54 __CFRunLoopRun + 868 21 CoreFoundation
0x0000000102551486 CFRunLoopRunSpecific + 470 22 GraphicsServices
0x0000000104bc09f0 GSEventRunModal + 161 23 UIKit
0x0000000102a13420 UIApplicationMain + 1282 24 DataMatrixReader
0x0000000100ef2343 main + 115 25 libdyld.dylib
0x00000001058a3145 start + 1 ) libc++abi.dylib: terminating with
uncaught exception of type NSException (lldb)
Now the question is somebody tried to integrate the ZxingObjC in iOS 8.1?
I think your project is using ARC but ZXING library isn't. In that case go to path 'Target -> Build Phases -> Compile Sources' in ZXING library. Double click on each .m file and enter '-fno-objc-arc' in popped dialog box. In this way those files will be excluded from ARC
If you project is using ARC (Automatic Reference Counting) then you don't need to make autorelease calls as it is done for you.
Change
ZXLuminanceSource *source = [[[ZXCGImageLuminanceSource alloc] initWithCGImage:imageToDecode] autorelease];
to
ZXLuminanceSource *source = [[ZXCGImageLuminanceSource alloc] initWithCGImage:imageToDecode];
Further information about ARC can be found on the iOS Developer Library
This works perfectly for me:
Getting Started in the readme.md didn’t work so I had to do the following steps to make it work.
copy the whole folders into your working project’s sub-folder.
and drag/add ZXingObjC.xcodeproj file to “<your working project>”.
make sure tick create folder references for any added folders option when prompted.
then, go to your project’s Target > Build Phases
under Target Dependencies, add ZXingObjC-iOS (ZXingObjC)
under Link Binary With Libraries, add libZXingObjC-iOS.a
under the same category, add the following 6 frameworks
AVFoundation.framework
CoreGraphics.framework
CoreMedia.framework
CoreVideo.framework
ImageIO.framework
QuartzCore.framework
Source in: http://sagage.com/?p=55
My test in a direct device Iphone 4s were good, perhaps is not the best device to test that, Iphone 4s has not a "AutoFocus" feature, very important for work with this barcodes.
hope this saves your day.

Real Time Plot in Plot_Gallery_iOS does not update plot Range in iPad

I have been exploring the project Plot_Gallery-iOS supplied with Core Plot release 1.5.1, specifically the RealTimePlot example. I tested the app in the simulators, both iPhone and iPad, also on the 64bit versions of these simulators. Then I ran the project on the iPhone, and everything went as expected. The problem occurred when I ran the project on an iPad Air. The first part of the real time plot works fine, but then, the range of the plot is not updated. The data is being updated, though, because the points are shifted, until the axes are left empty.
I added an exception break point to the project, and it stops on NSParameterAssert(range) in the method setXRange: of the CPTXYPlotSpace.m:
-(void)setXRange:(CPTPlotRange *)range
{
NSParameterAssert(range);
if ( ![range isEqualToRange:xRange] ) {
CPTPlotRange *constrainedRange;
if ( self.allowsMomentumX ) {
constrainedRange = range;
}
else {
constrainedRange = [self constrainRange:range toGlobalRange:self.globalXRange];
}
id<CPTPlotSpaceDelegate> theDelegate = self.delegate;
if ( [theDelegate respondsToSelector:#selector(plotSpace:willChangePlotRangeTo:forCoordinate:)] ) {
constrainedRange = [theDelegate plotSpace:self willChangePlotRangeTo:constrainedRange forCoordinate:CPTCoordinateX];
}
if ( ![constrainedRange isEqualToRange:xRange] ) {
[xRange release];
xRange = [constrainedRange copy];
[[NSNotificationCenter defaultCenter] postNotificationName:CPTPlotSpaceCoordinateMappingDidChangeNotification
object:self];
if ( [theDelegate respondsToSelector:#selector(plotSpace:didChangePlotRangeForCoordinate:)] ) {
[theDelegate plotSpace:self didChangePlotRangeForCoordinate:CPTCoordinateX];
}
CPTGraph *theGraph = self.graph;
if ( theGraph ) {
[[NSNotificationCenter defaultCenter] postNotificationName:CPTGraphNeedsRedrawNotification
object:theGraph];
}
}
}
}
The deployment target is 7.1 and the other project configurations are the ones that came with the project. Any clues on why is this happening?
Update
This is the stack trace before the exception:
2014-03-21 15:11:48.794 Plot Gallery[209:60b] Stack trace : (
0 Plot Gallery 0x0000000100150094 -[CPTXYPlotSpace setXRange:] + 56
1 Plot Gallery 0x00000001001a705c -[CPTAnimation update:] + 3040
2 Foundation 0x000000018a2c15c4 __NSFireTimer + 92
3 CoreFoundation 0x00000001896fef54 <redacted> + 28
4 CoreFoundation 0x00000001896febc4 <redacted> + 804
5 CoreFoundation 0x00000001896fc8ec <redacted> + 1324
6 CoreFoundation 0x000000018963d6d0 CFRunLoopRunSpecific + 452
7 GraphicsServices 0x000000018f2c9c0c GSEventRunModal + 168
8 UIKit 0x000000018c76efdc UIApplicationMain + 1156
9 Plot Gallery 0x00000001000def54 main + 56
10 libdyld.dylib 0x00000001965e7aa0 <redacted> + 4
)
2014-03-21 15:12:02.358 Plot Gallery[209:60b] *** Assertion failure in -[CPTXYPlotSpace setXRange:], /Users/myUser/Developer/iOS/core_plot/framework/Source/CPTXYPlotSpace.m:378
This was fixed after the 1.5.1 release. Either checkout the latest code from Github or wait for the next release.

Why my [UIScrollView removeFromSuperview] is crashing?

The crash log is below.
Do you know any particular reason why might [UIScrollView removeFromSuperview] can crash? The scrollview contains view hierarchy with different types of UIViews. I also finds that the ad hoc version crash often not the debug version. I could not find any reason for that.
Same viewcontroller is loaded in a different flow in iPhone that works fine. But in iPad it crashes.
In iPad, in a container view controller, only viewcontroler.view is loaded.
Incident Identifier: EE102239-34D1-4BE7-8B52-41F74AB26203
CrashReporter Key: 2b11ea2a01ac5618e199ffc5a1e1f321600bb6a9
Hardware Model: iPad3,4
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-06-18 15:19:16.132 +0200
OS Version: iOS 6.1.3 (10B329)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x3bab7070 prepareForMethodLookup + 20
1 libobjc.A.dylib 0x3bab6fb2 lookUpMethod + 42
2 libobjc.A.dylib 0x3bab6f7e _class_lookupMethodAndLoadCache3 + 14
3 libobjc.A.dylib 0x3bab6638 objc_msgSend_uncached + 24
4 QuartzCore 0x357f2a72 CA::Layer::contents_visibility_changed(CA::Transaction*, bool) + 50
5 QuartzCore 0x357f29de CA::Layer::mark_visible(CA::Transaction*, bool) + 190
6 QuartzCore 0x357f29b2 CA::Layer::mark_visible(CA::Transaction*, bool) + 146
7 QuartzCore 0x357f29b2 CA::Layer::mark_visible(CA::Transaction*, bool) + 146
8 QuartzCore 0x357f29b2 CA::Layer::mark_visible(CA::Transaction*, bool) + 146
9 QuartzCore 0x357f29b2 CA::Layer::mark_visible(CA::Transaction*, bool) + 146
10 QuartzCore 0x357f28d2 CA::Layer::update_removed_sublayer(CA::Transaction*, unsigned int) + 18
11 QuartzCore 0x357f255a CA::Layer::remove_sublayer(CA::Transaction*, CALayer*) + 130
12 QuartzCore 0x357f246a CA::Layer::remove_from_superlayer() + 34
13 UIKit 0x35a6e92c -[UIView(Hierarchy) removeFromSuperview] + 144
14 UIKit 0x35b857bc -[UIScrollView removeFromSuperview] + 60
15 MyApp 0x000bde8a -[iPadNavigationController vcAnimationDone] (iPadNavigationController.m:400)
16 UIKit 0x35a55ab6 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 154
17 UIKit 0x35aca8f8 -[UIViewAnimationState animationDidStop:finished:] + 44
18 QuartzCore 0x35801304 CA::Layer::run_animation_callbacks(void*) + 204
19 libdispatch.dylib 0x3bed55d8 _dispatch_client_callout + 20
20 libdispatch.dylib 0x3bed8e40 _dispatch_main_queue_callback_4CF + 224
21 CoreFoundation 0x33c051ac __CFRunLoopRun + 1284
22 CoreFoundation 0x33b78238 CFRunLoopRunSpecific + 352
23 CoreFoundation 0x33b780c4 CFRunLoopRunInMode + 100
24 GraphicsServices 0x37733336 GSEventRunModal + 70
25 UIKit 0x35a942b4 UIApplicationMain + 1116
A few line from the code (as asked),
previous = showing;
showing = [ vc retain ];
showing.view.frame = startFrameIn;
[ container addSubview:showing.view ];
CGContextRef context = UIGraphicsGetCurrentContext();
[ UIView beginAnimations:nil context:context ];
[ UIView setAnimationDelegate:self ];
[ UIView setAnimationDidStopSelector:#selector(vcAnimationDone) ];
[ UIView setAnimationCurve:UIViewAnimationCurveEaseOut ];
[ UIView setAnimationDuration:0.4 ];
previous.view.frame = endFrameOut;
showing.view.frame = detailFrame;
[ UIView commitAnimations ];
}
- (void) vcAnimationDone {
if ( previous != nil ) {
if (previous.view.superview != nil) {
[previous.view removeFromSuperview];
}
[ previous release ];
previous = nil;
}
A very probable reason is that you are overreleasing your scrollview or one of the views inside it.
Calling removeFromSuperview then deallocates the view instead of simply decreasing the retain count.
Actually, if you are still stuck with non-ARC project, Static Code Analysis is very useful for this kind of bug. Retain/release balancing issues are hard to pin down, and nearly impossible with incomplete method so I suggest you post the full method body if possible.
Thanks everyone for your answers, tips and tricks. However one thing I want share with you is the cause of the crash. I found that the crash was at different thread in different times. I had several views loaded with button pressing/menu in my iPad app. Some of the button pressing fetch data from web service. So I was bit confused to get the cuase of crash, animation, or url connection etc... I tried with enabled NSZombie objects, but it did not show any information.
Then I tried with Guard Malloc. This only runs in Simulator. And magically I found the code point of crash. I have function to convert a hex string into data. There I have line of code to make a C string null terminated. where I assigned 0 at the last index. and that makes the crash!
tmpCh[count] = 0;
I do not why, but probably it takes some time in the memory management procedure in iOS so it crash at different thread at different times. But with Guard malloc in Simulator, it always point out here and when I rewrite the code, the crash is gone.
/* Converts a hex string to bytes.
Precondition:
. The hex string can be separated by space or not.
. the string length without space or 0x, must be even. 2 symbols for one byte/char
. sample input: 23 3A F1 OR 233AF1
*/
+ (NSData *) dataFromHexString:(NSString*)hexString
{
if (hexString.length < 1) {
return nil;
}
char * tmpCh = (char *) malloc([hexString length] * sizeof(char));
int count = 0;
for (int k=0; k<hexString.length;k++) {
char c = [hexString characterAtIndex:k];
if (c == (char)0x20) { //skip space
continue;
}
if (c == '0') { // skip 0x
if(k+1 < hexString.length){
if ([hexString characterAtIndex:k+1] == 'x'
|| [hexString characterAtIndex:k+1] == 'X' )
{
k = k + 1;
continue;
}
}
}
tmpCh[count] = c;
count++;
}
tmpCh[count] = 0; // make null terminated string
if (count % 2) {
return nil;
}
NSString *temp = [[NSString alloc] initWithUTF8String:tmpCh];
free(tmpCh);
if ([temp length] % 2 != 0) {
return nil;
}
NSMutableData *result = [[NSMutableData alloc] init];
unsigned char byte;
char hexChars[3] = {0};
for (int i=0; i < (temp.length/2); i++) {
hexChars[0] = [temp characterAtIndex:i*2];
hexChars[1] = [temp characterAtIndex:i*2+1];
if (![Util isValidChar:hexChars[0]] || ![Util isValidChar:hexChars[1]]) {
return nil;
}
byte = strtol(hexChars, NULL, 16);
[result appendBytes:&byte length:1];
}
NSData * data = [NSData dataWithData:result];
[result release];
return data;
}

Resources