ios UILabel setFrame error - ios

#import <QuartzCore/QuartzCore.h>
- (void)viewDidLoad
{
[self.forwardView setFrame:CGRectMake(12.0, 40.0+height, 296.0, rootViewHeight-15.0)];
self.forwardView.layer.borderColor = [UIColor colorWithRed:153.0/250.0 green:153.0/250.0 blue:153.0/250.0 alpha:100].CGColor;
self.forwardView.layer.borderWidth = 1;
CGRect frame = CGRectMake(12.0f, 40.0f, 288.0f , height);
[self.tvContent setFrame:frame];
}
[self.tvContent setFrame:frame]; //crash?
Exception message:
-[__NSCFString setFrame:]: unrecognized selector sent to instance 0x7894c00
2013-05-21 10:44:54.677 Sohappy[22295:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString setFrame:]: unrecognized selector sent to instance 0x7894c00'
*** First throw call stack:
(0x1eb5012 0x19aae7e 0x1f404bd 0x1ea4bbc 0x1ea494e 0xfb407 0xfc20b 0x9d01c7 0x9d0232 0x9d04da 0x9e78e5 0x9e79cb 0x9e7c76 0x9e7d71 0x9e889b 0x9e8e93 0x8ef13f7 0x9e8a88 0x93b9 0x99df83 0x99e4ed 0x13a85b3 0x1e74376 0x1e73e06 0x1e5ba82 0x1e5af44 0x1e5ae1b 0x24e27e3 0x24e2668 0x8eeffc 0x2acd 0x29f5 0x1)
libc++abi.dylib: terminate called throwing an exception
UILabel in .xib , UseAutoLayout, ios sdk 6.1

You are trying to set the frame of an NSString - something that doesn't exist. self.tvContent is an NSString, not a UILabel as you seem to have suspected.
This is a good chance to learn how to read exceptions. I'll break it down for you here:
-[__NSCFString setFrame:]: unrecognized selector sent to instance 0x7894c00
2013-05-21 10:44:54.677 Sohappy[22295:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString setFrame:]: unrecognized selector sent to instance 0x7894c00'
*** First throw call stack:
(0x1eb5012 0x19aae7e 0x1f404bd 0x1ea4bbc 0x1ea494e 0xfb407 0xfc20b 0x9d01c7 0x9d0232 0x9d04da 0x9e78e5 0x9e79cb 0x9e7c76 0x9e7d71 0x9e889b 0x9e8e93 0x8ef13f7 0x9e8a88 0x93b9 0x99df83 0x99e4ed 0x13a85b3 0x1e74376 0x1e73e06 0x1e5ba82 0x1e5af44 0x1e5ae1b 0x24e27e3 0x24e2668 0x8eeffc 0x2acd 0x29f5 0x1)
libc++abi.dylib: terminate called throwing an exception
Here's what you are interested in:
-[__NSCFString setFrame:]: unrecognized selector sent to instance 0x7894c00
The system is giving you the class of the object and the message you tried to send it - in this case an NSString that you tried to call setFrame: on.
This information coupled with that you know which line is crashing makes for an easy conclusion: self.tvContent is an NSString where you were probably expecting a UILabel.

-[__NSCFString setFrame:]
Your app thinks that tvContent is a string, not a view. Make sure your outlet is connected to your UI correctly. Additionally, if you have a property for tvContent, it needs to be an owning reference (eg strong (under ARC) or retain (non-ARC)).

Related

UIViewController throws 'unrecognized selector' error

I've created a XIB containing only a UITableView. I changed the parameters of the project to load this view at launch. But I get this "unrecognized selector sent to instance" error I don't know what it is. How do I fix this and get my app to show my view ?
I've searched the web and it seems that might come from Objective-C libraries ?
EDIT
I did some testing, it's look like it crashes when I link my TableView with my IBOutlet in the ViewController. Am I doing something wrong with the type TableView ?
The viewcontroller :
class Liste: UIViewController {
#IBOutlet weak var maListe: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
}
}
The error stack :
2019-06-12 14:06:11.083905+0200 GuildWar[5905:8796162]
-[GuildWar.Liste _finishDecodingLayoutGuideConnections:]: unrecognized selector sent to instance 0x104f0ef40 2019-06-12 14:06:17.511280+0200
GuildWar[5905:8796162] * Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[GuildWar.Liste
_finishDecodingLayoutGuideConnections:]: unrecognized selector sent to instance 0x104f0ef40'
* First throw call stack: (0x21230f518 0x2114ea9f8 0x21222c278 0x23e4c2ef8 0x212314d60 0x2123169fc 0x23e874110 0x21c955f28
0x21c8f5304 0x212cdba4c 0x21c955f28 0x21c95616c 0x21c8f5304
0x23e151dcc 0x23e152958 0x23e4971e4 0x23e4977c0 0x23e495e24
0x23dd5a104 0x23dd6269c 0x23dd59d88 0x23dd5a678 0x23dd589c4
0x23dd5868c 0x23dd5d1cc 0x23dd5dfb0 0x23dd5d084 0x23dd61d84
0x23e494518 0x23e090f0c 0x214c89d44 0x214c93754 0x214c92f5c
0x104cbcc74 0x104cc0840 0x214cc40bc 0x214cc3d58 0x214cc4310
0x2122a12bc 0x2122a123c 0x2122a0b24 0x21229ba60 0x21229b354
0x21449b79c 0x23e497b68 0x1045ea10c 0x211d618e0) libc++abi.dylib:
terminating with uncaught exception of type NSException
It looks like, you might have created IBOutlet or IBAction and deleted later in the code. Revisit the connections in the storyboard connection inspectors and check if there is any warning symbol like the attached screenshot, then you need to remove that connection.
Or if you can share your code I can look into.

-[UIView adjustedContentInset]: unrecognized selector sent to instance in ios 11

> Scrollview have content view to manage subviews,
Error comes in ios 11 work fine in ios 10
-[UIView adjustedContentInset]: unrecognized selector sent to instance 0x10296d680 2017-10-02 12:34:11.931454+0530
MobifinX1_Subscriber[1235:135465] * Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '-[UIView
adjustedContentInset]: unrecognized selector sent to instance
0x10296d680'
* First throw call stack: (0x186f53d38 0x186468528 0x186f611f8 0x19071bcc4 0x186f596e4 0x186e3f0dc 0x1906f2628 0x1906f23f0
0x1906f1bc0 0x1906f18f0 0x19040c964 0x1904e8e48 0x19040ae04
0x19040aa34 0x19040a95c 0x190361000 0x18af310b4 0x18af35194
0x18aea3f24 0x18aeca340 0x1905c7744 0x190ca6718 0x190c9f574
0x186efc358 0x186efc2d8 0x186efbb60 0x186ef9738 0x186e1a2d8
0x188cabf84 0x1903c7880 0x100abcb5c 0x18693e56c) libc++abi.dylib:
terminating with uncaught exception of type NSException
Answer - we can not take iboulet of uiview inside uiscrollview with named contentScrollView.

how to catch Terminating app due to uncaught exception: NSArrayM objectAtIndex index 0 beyond bounds for empty array

*** Terminating app due to uncaught exception 'NSRangeException', reason: '
*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x276b2fef 0x35ba6c8b 0x275c5841 0xe78bb 0xfe689 0x2b19e281 0x2b19ebab 0x2aedc981 0x2b19ea63 0x2b19f1b3 0x2afac2df 0x2b1943a7 0x2afa34d7 0x2aecd003 0x2a8eefc1 0x2a8ea7fd 0x2a8ea685 0x2a8ea031 0x2a8e9e1f 0x2a8e3b79 0x27678ffd 0x276766bb 0x27676ac3 0x275c3221 0x275c3033 0x2eff2201 0x2af2f8c9 0x114b59 0x36156aaf)
libc++abi.dylib: terminating with uncaught exception of type NSException
I have many [NSArray objectAtIndex], I don't know which one makes it crash.
I've writen the debug code below, but still can't catch it. It's in a UITableView, I load more and more cells by pull down the table, then it sometimes crashes.
#import "NSArray+Debug.h"
#import "MLTool.h"
#implementation NSArray (Debug)
- (id)objectAtIndexEx:(NSUInteger)index{
if (self.count<1) {
assert(0);
}
NSString *str=[NSString stringWithFormat:#"count=%d,index=%d,info=%#",self.count,index,[self objectAtIndex:index]];
if ([MLTool isEmptyString:str]
// ||str==
) {
assert(0);
}
NSLogUTF8(#"break:%#",str);
return [self objectAtIndex:index];
}
#end
You can add an "exception breakpoint" in xcode to stop your debugging at the moment of the crash and check why it will crash.
For that in the section breakpoint/debug of the left navigator you can tap on the "+" at the bottom-left corner to add an "Exception breakpoint".

NSInvalidArgumentException - XCode 6.0.1

I realize this error has been discussed many times on stackoverflow, but I'm still not sure what I'm missing. Here's the console output:
Unknown class CRBarGraphController in Interface Builder file.
2014-11-18 18:40:05.796 Test[7319:60b] -[UIImageView start2]: unrecognized selector sent to instance 0x16562ac0
2014-11-18 18:40:06.256 Test[7319:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView start2]: unrecognized selector sent to instance 0x16562ac0'
CRBarGraphController.m defines a function (void)start2; also declared in the interface for CRBarGraphController.h.
start2 is called from CRGraphViewController.m using the following code:
-(void)viewWillAppear:(BOOL)animated {
self.navigationController.navigationBarHidden = NO;
[self.bar_Graph start2];
}
where, bar_Graph is an object of CRBarGraphController, declared in CRGraphViewController.h as:
#property (weak, nonatomic) IBOutlet CRBarGraphController *bar_Graph;
CRGraphViewController.h does import CRBarGraphController.h
Also, in the storyboard, bar_Graph outlet is set to class, CRBarGraphController.
Why does XCode still think bar_Graph is an instance of UIImageView and not CRBarGraphComtroller? I included an exception breakpoint to make sure the exception originates from where start2 is being called.

selector syntax: why I am getting unrecognized selector error?

I have a method to compare 2 objects:
- (NSComparisonResult)compare:(NSObject *)object1 to:(NSObject *)object2{
// do some stuff
return NSOrderedSame; // or NSOrderedAscending or NSOrderedDescending
}
This method gets called like this:
NSArray *sortedSyncedAufgaben = [syncedAufgabe sortedArrayUsingSelector:#selector(compare:to:)];
Now, when I run this on my iPhone, a "unrecognized selector error" is thrown in the line with the selector:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ImpfVorgang compare:to:]: unrecognized selector sent to instance 0x14ebf040'
What is wrong? I thought for each parameter I need a colon?
sortedArrayUsingSelector: tries to apply you selector to the object on the left-hand side of the comparison, not to the class that calls sortedArrayUsingSelector:. In other words, if the selector exists in your class that initiates the sort, not in the class of the object inside NSArray (i.e. not in your ImpfVorgang class), you are going to see an "unrecognized selector error".
You can change your code to apply the selector manually, like this:
NSArray * sortedSyncedAufgaben = [syncedAufgabe sortedArrayUsingComparator:^(NSObject *a, NSObject* b) {
return [self compare:a to:b];
}];
Alternatively, you could move the comparison logic into the comparator block, and drop the compare:to: method altogether.

Resources