Calling method is causing Error creating LLDB target - ios

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];

Related

When I use a NSMutableArray which as a property of a Singleton , to add some object into the NSMutableArray. It crushed

Here is my sampleCode :
-(IBAction)add:(id)sender {
//ShoppingManager sharedManager is a singleton
[[ShoppingManager sharedManager].onlineClassArray addObject:#(1)];
}
and code in ShoppingManager.m:
//singleton
+ (ShoppingManager *)sharedManager{
static id instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[self alloc]init];
});
return instance;
}
- (OnlineClassItemizeArray *)onlineClassArray{
if (!_onlineClassArray) {
_onlineClassArray = [OnlineClassItemizeArray array];
}
return _onlineClassArray;
}
and the ShoppingMananger.h:
#interface ShoppingManager : NSObject
#property(nonatomic,strong) OnlineClassItemizeArray * onlineClassArray;
+ (ShoppingManager*)sharedManager;
#end
I don't know what is wrong with these codes.when i added some object into the mutableArray,it stopped at this line:(a all Exception BreakPoint)
_onlineClassArray = [OnlineClassItemizeArray array];
than crushed at here:
DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead")
void
_dispatch_once(dispatch_once_t *predicate,
DISPATCH_NOESCAPE dispatch_block_t block)
{
if (DISPATCH_EXPECT(*predicate, ~0l) != ~0l) {
dispatch_once(predicate, block);//<---crushed here
} else {
dispatch_compiler_barrier();
}
DISPATCH_COMPILER_CAN_ASSUME(*predicate == ~0l);
}
and here is the whole error msg:
2017-03-14 01:01:36.586 tesr1111[7075:1333259] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableArray initWithCapacity:]: method only defined for abstract class. Define -[OnlineClassItemizeArray initWithCapacity:]!'
*** First throw call stack:
(
0 CoreFoundation 0x00000001100c4d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010fb2621e objc_exception_throw + 48
2 CoreFoundation 0x00000001101357df __CFRequireConcreteImplementation + 255
3 CoreFoundation 0x00000001101241a7 -[NSMutableArray initWithCapacity:] + 39
4 tesr1111 0x000000010f54e6d0 -[ShoppingManager init] + 160
5 tesr1111 0x000000010f54e5f1 __32+[ShoppingManager sharedManager]_block_invoke + 65
6 libdispatch.dylib 0x0000000112eda0cd _dispatch_client_callout + 8
7 libdispatch.dylib 0x0000000112ebf1f8 dispatch_once_f + 501
8 tesr1111 0x000000010f54e588 +[ShoppingManager sharedManager] + 136
9 tesr1111 0x000000010f54de9d -[ViewController add:] + 61
10 UIKit 0x00000001104ea8bc -[UIApplication sendAction:to:from:forEvent:] + 83
11 UIKit 0x0000000110670c38 -[UIControl sendAction:to:forEvent:] + 67
12 UIKit 0x0000000110670f51 -[UIControl _sendActionsForEvents:withEvent:] + 444
13 UIKit 0x000000011066fe4d -[UIControl touchesEnded:withEvent:] + 668
14 UIKit 0x0000000110558545 -[UIWindow _sendTouchesForEvent:] + 2747
15 UIKit 0x0000000110559c33 -[UIWindow sendEvent:] + 4011
16 UIKit 0x00000001105069ab -[UIApplication sendEvent:] + 371
17 UIKit 0x0000000120cca481 -[UIApplicationAccessibility sendEvent:] + 93
18 UIKit 0x0000000110cf372d __dispatchPreprocessedEventFromEventQueue + 3248
19 UIKit 0x0000000110cec463 __handleEventQueue + 4879
20 CoreFoundation 0x0000000110069761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
21 CoreFoundation 0x000000011004e98c __CFRunLoopDoSources0 + 556
22 CoreFoundation 0x000000011004de76 __CFRunLoopRun + 918
23 CoreFoundation 0x000000011004d884 CFRunLoopRunSpecific + 420
24 GraphicsServices 0x0000000113eb0a6f GSEventRunModal + 161
25 UIKit 0x00000001104e8c68 UIApplicationMain + 159
26 tesr1111 0x000000010f54e4df main + 111
27 libdyld.dylib 0x0000000112f2668d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
If anyone can give me any idea or helping link. Thanks in advance.
You are subclassing NSMutableArray incorrectly. It is a class cluster and there is a minimum set of methods that need to be implemented.
In this case, you are calling initWithCapacity: but haven't overridden that method. Or, more likely, you are calling a generic method (init) that calls through to that method.
Exactly as the exception says:
2017-03-14 01:01:36.586 tesr1111[7075:1333259] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[NSMutableArray initWithCapacity:]: method only defined for abstract class. Define -[OnlineClassItemizeArray initWithCapacity:]!'
However, subclassing the collection classes is a code smell. It is pretty much never done. There are rare cases where it makes sense; what is yours?

How to retrive dynamically created Class in Realm?

I am adding Realm source files in my project. I want to create realm class dynamically. Following is my demo code:
-(void)createDynamicClassObject
{
[self createDynamicSchema];
[self createDynamicSchema2];
}
-(void)createDynamicSchema{
_schema = [[RLMSchema alloc] init];
RLMProperty *prop = [[RLMProperty alloc] initWithName:#"a"
type:RLMPropertyTypeInt
objectClassName:nil
linkOriginPropertyName:nil
indexed:NO
optional:NO];
RLMObjectSchema *objectSchema1 = [[RLMObjectSchema alloc] initWithClassName:#"TrulyDynamicObject"
objectClass:RLMObject.class properties:#[prop]];
_schema.objectSchema = #[objectSchema1];
NSLog(#"dyrealm %#",_dyrealm);
NSLog(#"schema %#",[_schema schemaForClassName:#"TrulyDynamicObject"]);
}
-(void)createDynamicSchema2 {
RLMProperty *prop1 = [[RLMProperty alloc] initWithName:#"apple"
type:RLMPropertyTypeString
objectClassName:nil
linkOriginPropertyName:nil
indexed:NO
optional:NO];
RLMProperty *prop2 = [[RLMProperty alloc] initWithName:#"banana"
type:RLMPropertyTypeFloat
objectClassName:nil
linkOriginPropertyName:nil
indexed:NO
optional:NO];
RLMProperty *prop3 = [[RLMProperty alloc] initWithName:#"Mango"
type:RLMPropertyTypeObject
objectClassName:#"TrulyDynamicObject"
linkOriginPropertyName:nil
indexed:NO
optional:NO];
RLMObjectSchema *objectSchema = [[RLMObjectSchema alloc] initWithClassName:#"DynamicTestObject"
objectClass:RLMObject.class properties:#[prop1,prop2,prop3]];
NSMutableArray *array = [NSMutableArray arrayWithArray:_schema.objectSchema];
[array addObject:objectSchema];
_schema.objectSchema = array;
_dyrealm = [self realmWithTestPathAndSchema:_schema];
NSLog(#"DynamicTestObject dyrealm %#",_dyrealm);
NSLog(#"DynamicTestObject schema %#",[_schema schemaForClassName:#"DynamicTestObject"]);
}
while creating schema2, app is crashing.
2016-06-17 15:10:13.491 realmLibraryDemo[1770:82980] schema TrulyDynamicObject {
a {
type = int;
objectClassName = (null);
linkOriginPropertyName = (null);
indexed = NO;
isPrimary = NO;
optional = NO;
}
}
2016-06-17 15:10:13.499 realmLibraryDemo[1770:82980] *** Terminating app due to uncaught exception 'RLMException', reason: 'Schema validation failed due to the following errors:
- 'Object' property 'Mango' must be nullable.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010217ae65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000101bf1deb objc_exception_throw + 48
2 Realm 0x0000000101281c49 _Z18RLMSetErrorOrThrowP7NSErrorPU15__autoreleasingS0_ + 985
3 Realm 0x00000001012606e6 _Z26RLMRealmTranslateExceptionPU15__autoreleasingP7NSError + 598
4 Realm 0x0000000101260dfc +[RLMRealm openSharedRealm:error:] + 268
5 Realm 0x0000000101261e66 +[RLMRealm realmWithConfiguration:error:] + 4022
6 realmLibraryDemo 0x0000000100fa4eb9 -[ViewController realmWithTestPathAndSchema:] + 217
7 realmLibraryDemo 0x0000000100fa4cb8 -[ViewController createDynamicSchema2] + 776
8 realmLibraryDemo 0x0000000100fa46f6 -[ViewController createDynamicClassObject] + 70
9 realmLibraryDemo 0x0000000100fa42d0 -[ViewController viewDidLoad] + 288
10 UIKit 0x00000001026bef98 -[UIViewController loadViewIfRequired] + 1198
11 UIKit 0x00000001026bf2e7 -[UIViewController view] + 27
12 UIKit 0x0000000102595ab0 -[UIWindow addRootViewControllerViewIfPossible] + 61
13 UIKit 0x0000000102596199 -[UIWindow _setHidden:forced:] + 282
14 UIKit 0x00000001025a7c2e -[UIWindow makeKeyAndVisible] + 42
15 UIKit 0x0000000102520663 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
16 UIKit 0x0000000102526cc6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1760
17 UIKit 0x0000000102523e7b -[UIApplication workspaceDidEndTransaction:] + 188
18 FrontBoardServices 0x0000000104f28754 -[FBSSerialQueue _performNext] + 192
19 FrontBoardServices 0x0000000104f28ac2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
20 CoreFoundation 0x00000001020a6a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
21 CoreFoundation 0x000000010209c95c __CFRunLoopDoSources0 + 556
22 CoreFoundation 0x000000010209be13 __CFRunLoopRun + 867
23 CoreFoundation 0x000000010209b828 CFRunLoopRunSpecific + 488
24 UIKit 0x00000001025237cd -[UIApplication _run] + 402
25 UIKit 0x0000000102528610 UIApplicationMain + 171
26 realmLibraryDemo 0x0000000100fa562f main + 111
27 libdyld.dylib 0x00000001048ce92d start + 1
28 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
How to check whether TrulyDynamicObject is created or not as when I executed code using only [self createDynamicSchema]; it is working fine.
Anybody knows how to create multiple schemas with realm object as a reference when class is dynamically created?
From the "Optional Properties" section of Realm's docs (link):
RLMObject subclass properties always can be nil and thus cannot be included in requiredProperties, and RLMArray does not support storing nil.
Translated into RLMProperty wording, it means that properties of type RLMPropertyTypeObject must be optional since the underlying data format can't guarantee that there will always be a link there.

App crashes while using NSURL URLWithString in a "for" loop

Here's my code,
for (int i=0; i<=[selfLinksArray count]; i++) {
NSString *temp = selfLinksArray[i];
NSURL *tempURL = [NSURL URLWithString:temp ];
NSLog(#"NSURL:%#",tempURL);
NSData *tempData = [NSData dataWithContentsOfURL:tempURL];
NSError *error = nil;
NSDictionary *tempDict = [NSJSONSerialization JSONObjectWithData:tempData options:0 error:&error];
NSDictionary *volumeInfoDict = [tempDict objectForKey:#"volumeInfo"];
titleArray[i]=[volumeInfoDict objectForKey:#"title"];
}
Xcode shows me this error
[__NSArrayI length]: unrecognized selector sent to instance 0x7fdf334f0bc0
2016-01-19 16:12:34.937 BookFindr[7775:449799] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI length]: unrecognized selector sent to instance 0x7fdf334f0bc0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010f34be65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010edc4deb objc_exception_throw + 48
2 CoreFoundation 0x000000010f35448d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010f2a190a ___forwarding___ + 970
4 CoreFoundation 0x000000010f2a14b8 _CF_forwarding_prep_0 + 120
5 CoreFoundation 0x000000010f32e261 _CFURLCreateWithURLString + 81
6 Foundation 0x000000010e97a465 -[NSURL(NSURL) initWithString:relativeToURL:] + 349
7 Foundation 0x000000010e97a2e2 +[NSURL(NSURL) URLWithString:relativeToURL:] + 59
8 BookFindr 0x000000010e8bf9ab -[tabResTableViewController viewDidLoad] + 219
9 UIKit 0x000000010f88ef98 -[UIViewController loadViewIfRequired] + 1198
10 UIKit 0x000000010f894f4f -[UIViewController __viewWillAppear:] + 120
11 UIKit 0x000000010f8c4e44 -[UINavigationController _startCustomTransition:] + 1203
12 UIKit 0x000000010f8d523f -[UINavigationController _startDeferredTransitionIfNeeded:] + 712
13 UIKit 0x000000010f8d63af -[UINavigationController __viewWillLayoutSubviews] + 57
14 UIKit 0x000000010fa7cff7 -[UILayoutContainerView layoutSubviews] + 248
15 UIKit 0x000000010f7af4a3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
16 QuartzCore 0x000000011327b59a -[CALayer layoutSublayers] + 146
17 QuartzCore 0x000000011326fe70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
18 QuartzCore 0x000000011326fcee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
19 QuartzCore 0x0000000113264475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
20 QuartzCore 0x0000000113291c0a _ZN2CA11Transaction6commitEv + 486
21 UIKit 0x000000010f6f2f7c _UIApplicationHandleEventQueue + 7329
22 CoreFoundation 0x000000010f277a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
23 CoreFoundation 0x000000010f26d95c __CFRunLoopDoSources0 + 556
24 CoreFoundation 0x000000010f26ce13 __CFRunLoopRun + 867
25 CoreFoundation 0x000000010f26c828 CFRunLoopRunSpecific + 488
26 GraphicsServices 0x0000000112b08ad2 GSEventRunModal + 161
27 UIKit 0x000000010f6f8610 UIApplicationMain + 171
28 BookFindr 0x000000010e8c101f main + 111
29 libdyld.dylib 0x0000000111a8792d start + 1
30 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I have imported selfLinkArray from another viewController. I want to fetch various titles which are present in VolumeInfo dictionary. This dictionary is present in each individual link in selfLinksArray. Please help me with this error. Thanks in Advance.
Let's analyze your error and your backtrace :
-[__NSArrayI length]: unrecognized selector sent to instance 0x7fdf334f0bc0'
The issue is written here: the length method is called on an NSArray object.
Wait, this method is not even written in this sample! Don't worry, let's analyze it.
6 Foundation 0x000000010e97a465
-[NSURL(NSURL) initWithString:relativeToURL:] + 349
7 Foundation 0x000000010e97a2e2 +[NSURL(NSURL) URLWithString:relativeToURL:]
The crash log indicates that the crash occurs when you try to init the NSURL object. The only parameter of this init method is a NSString object. But are we sure that temp is really a NSString object ?
This variable is casted without checking if it's really an NSString object. It can be anthing, for example... the NSArray which receive a call to the length method. Also, this method is existing for a NSString object, so the unrecognizer selector error look totally related.
Where do you we call length on this NSString object ? My guess is, according to the backtrace, that URLWithString: call this method to check the NSString length in order to initialize properly the NSURL object.

Error EXC_BAD_ACCESS when pressing button

When i press my button, i got a error of access.
the error : Thread 1 : EXC_BAD_ACCESS(code=1,address=0xd0a937db)
TTest.h
#interface TTtest : NSObject
{
UIButton *monBouton ;
UIImage *skin;
}
- (void)initTest :(UIView*)vueDonne;
-(void)test:(id)sender;
TTest.m
- (void)initTest :(UIView*)vueDonne
{
skin = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:#"boutonG" ofType:#"png"]];
monBouton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
monBouton.frame = CGRectMake(50, 50, 45, 50);
[monBouton setImage:skin forState:UIControlStateNormal];
[monBouton addTarget:self action:#selector(test:) forControlEvents:UIControlEventTouchDown];
[vueDonne addSubview: monBouton];
}
-(void)test:(id)sender //didn't work because i have the probleme
{
NSLog(#"test clicked");
}
testViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
TTtest *test =[[TTtest alloc] init];
[test initTest:_testView]; //View of my application
}
EDIT:
If i add monBouton = [[UIButton alloc] init];
I get a problem of SIGABRT
2014-10-26 16:47:22.827 testAsk[2134:a0b] -[CALayerArray test:]: unrecognized selector sent to instance 0xa141ea0
2014-10-26 16:47:22.831 testAsk[2134:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayerArray test:]: unrecognized selector sent to instance 0xa141ea0'
*** First throw call stack:
(
0 CoreFoundation 0x017395e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bc8b6 objc_exception_throw + 44
2 CoreFoundation 0x017d6903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0172990b ___forwarding___ + 1019
4 CoreFoundation 0x017294ee _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x014ce874 -[NSObject performSelector:withObject:withObject:] + 77
6 UIKit 0x0022c0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x0022c04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x003240c1 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x00324484 -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x003231fd -[UIControl touchesBegan:withEvent:] + 254
11 UIKit 0x0026934b -[UIWindow _sendTouchesForEvent:] + 386
12 UIKit 0x0026a184 -[UIWindow sendEvent:] + 1232
13 UIKit 0x0023de86 -[UIApplication sendEvent:] + 242
14 UIKit 0x0022818f _UIApplicationHandleEventQueue + 11421
15 CoreFoundation 0x016c283f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16 CoreFoundation 0x016c21cb __CFRunLoopDoSources0 + 235
17 CoreFoundation 0x016df29e __CFRunLoopRun + 910
18 CoreFoundation 0x016deac3 CFRunLoopRunSpecific + 467
19 CoreFoundation 0x016de8db CFRunLoopRunInMode + 123
20 GraphicsServices 0x0368e9e2 GSEventRunModal + 192
21 GraphicsServices 0x0368e809 GSEventRun + 104
22 UIKit 0x0022ad3b UIApplicationMain + 1225
23 testAsk 0x000027bd main + 141
24 libdyld.dylib 0x01d75725 start + 0
25 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
The reason for the crash is that test object is dealloced when it receives the button action.
TTtest *test =[[TTtest alloc] init]; //dealloced after viewDidLoad
so try to make the test a property and use self.test.
self.test =[[TTtest alloc] init];
Doesn't look like you defined the selector "test"
-(void)test: (id) sender
NSLog(#"test clicked");
}

[GADSlot state]: unrecognized selector sent to instance in iphone

I am new to iOS development.
I am trying to implementing admob ads in iOS in my phonegap app so I googled & found somveadmob without plugin.
after following all procedure,
I got an error MyApp[2388:70b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GADSlot state]: unrecognized selector sent to instance 0x10415920'**
so I google about & found that I have to change other Linker flags. (-ObjC)here
I have tried it but it is not working.
I am getting this error.
this solution also not working for me. [GADSlot state]: unrecognized selector sent to instance
2014-04-21 13:04:41.252 MyApp[2388:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GADSlot state]: unrecognized selector sent to instance 0x10415920'
*** First throw call stack:
(
0 CoreFoundation 0x038a85e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x02acb8b6 objc_exception_throw + 44
2 CoreFoundation 0x03945903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0389890b ___forwarding___ + 1019
4 CoreFoundation 0x038984ee _CF_forwarding_prep_0 + 14
5 MyApp 0x0001a01e -[GADSlot isMakingRequest] + 36
6 MyApp 0x00019c7d -[GADSlot setAdType:andReloadRequest:] + 334
7 MyApp 0x00018a5e -[GADBannerView setAdSize:andReload:] + 512
8 MyApp 0x00019052 -[GADBannerView setAdSize:] + 62
9 MyApp 0x00019381 -[GADBannerView initWithAdSize:] + 171
10 MyApp 0x00003e17 -[MainViewController viewDidLoad] + 118
11 UIKit 0x0021c318 -[UIViewController loadViewIfRequired] + 696
12 UIKit 0x0021c5b4 -[UIViewController view] + 35
13 MyApp 0x00002997 -[AppDelegate application:didFinishLaunchingWithOptions:] + 763
14 UIKit 0x00102355 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
15 UIKit 0x00102b95 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
16 UIKit 0x001073a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
17 UIKit 0x0011b87c -[UIApplication handleEvent:withNewEvent:] + 3447
18 UIKit 0x0011bde9 -[UIApplication sendEvent:] + 85
19 UIKit 0x00109025 _UIApplicationHandleEvent + 736
20 GraphicsServices 0x038062f6 _PurpleEventCallback + 776
21 GraphicsServices 0x03805e01 PurpleEventCallback + 46
22 CoreFoundation 0x03823d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
23 CoreFoundation 0x03823a9b __CFRunLoopDoSource1 + 523
24 CoreFoundation 0x0384e77c __CFRunLoopRun + 2156
25 CoreFoundation 0x0384dac3 CFRunLoopRunSpecific + 467
26 CoreFoundation 0x0384d8db CFRunLoopRunInMode + 123
27 UIKit 0x00106add -[UIApplication _run] + 840
28 UIKit 0x00108d3b UIApplicationMain + 1225
29 MyApp 0x000025fd main + 95
30 MyApp 0x00002595 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
please help me out.
main.m
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, #"AppDelegate");//It highlight this line when exception accoure.
[pool release];
return retVal;
}
MainViewController.m
- (void) viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
bannerView_ = [[GADBannerView alloc]initWithAdSize:kGADAdSizeSmartBannerPortrait];
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
CGFloat screenXPos = (screenWidth/2);
CGFloat screenYPos = screenHeight - kGADAdSizeBanner.size.height;
[bannerView_ setCenter:CGPointMake(screenXPos, screenYPos)];
bannerView_.adUnitID = MY_BANNER_UNIT_ID;
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
GADRequest *request = [GADRequest request];
request.testing = NO;
[bannerView_ loadRequest:request];
}
I think, GADBannerView is not set up correctly. If you have the source for GADBannerView, examine it and see where the object reference is coming from.U should try to solve this error in that direction.
check ur admob version as well, becoz GDBBannerview is a part of Admob this might accour from that code.
or else try with other (older or newer version) of admob api.

Resources