I get this error in my code 'NSInvalidArgumentException', - ios

2015-02-03 22:44:17.468 descuentos[1430:55158] -[UIButton value]: unrecognized selector sent to instance 0x7fde78d95440
2015-02-03 22:44:17.472 descuentos[1430:55158] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIButton value]: unrecognized selector sent to instance 0x7fde78d95440'
*** First throw call stack:
How can I fix this error? I think this is a thread error.
Here is my code:
- (IBAction)TipsSlider:(id)sender {
UISlider *slider = sender;
float valorFloat = slider.value;
int valInt = (int)valorFloat;
_dataSlider.text = [[NSString alloc]initWithFormat:#"%d", valInt];
}
- (IBAction)calcular:(id)sender {
UISlider *slider = sender;
float valorFloat = slider.value;
int valInt = (int)valorFloat;
_dataSlider.text = [[NSString alloc]initWithFormat:#"%d", valInt];
float valorIn= [[entrada text] floatValue];
float resultado = (valorFloat / 100) * valorIn;
NSString *resultadoFinal = [[NSString alloc]initWithFormat:#"%4.2f",resultado];
_salidaResultado.text = resultadoFinal;
}

It looks like you have connected an IBAction from a UIButton when you intended to use a UISlider.
You then assign the sender of the action (which is a button) to a slider and try to access its "value", only that UIButton instances do not respond to a "value" message and that's why you get the crash.
So, make sure you are "ctrl+dragging" from a slider in IB.

Related

jwplayer uncaught exception in ios

I'm trying to implement jwplayer in ios app but using a very simple startup it is continuously throwing signal abort error
#interface ViewController () <JWPlayerDelegate>
#property JWPlayerController *player;
#end
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self createPlayer];
}
- (void)createPlayer
{
JWConfig *config = [JWConfig configWithContentURL:#"http://content.bitsontherun.com/videos/3XnJSIm4-injeKYZS.mp4"];
config.autostart = YES;
self.player = [[JWPlayerController alloc] initWithConfig:config];
config.size = CGSizeMake(100, 100);
_player.view.frame = CGRectMake(0, 0, 100, 100);
[self.view addSubview:self.view];
}
#end
Error:
jwplayercheck[4111:850586] -[JWConfig xmlPlayList]: unrecognized selector sent to instance 0x1701256e0
2016-12-21 15:14:31.827747 jwplayercheck[4111:850586] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[JWConfig xmlPlayList]: unrecognized selector sent to instance 0x1701256e0'
* First throw call stack:
(0x1820321c0 0x180a6c55c 0x182039278 0x182036278 0x181f3059c 0x1000e38bc 0x1000be750 0x1000b4f68 0x1000b4a00 0x1000d9770 0x1000d97e0 0x1000ab850 0x1000ab7c4 0x187e860b0 0x187e85c78 0x187e8c424 0x187e898c4 0x187efc0e8 0x188108a78 0x18810e5c8 0x188122e60 0x18810b5ac 0x183bd98bc 0x183bd9728 0x183bd9ad0 0x181fe0278 0x181fdfbc0 0x181fdd7c0 0x181f0c048 0x187ef12b0 0x187eec034 0x1000ac414 0x180ef05b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
[Change Other Linker Flags on Build Setting to "-all_load"]

ios [__NSCFNumber length]: unrecognized selector sent to instance

i have created one custom cell and put button on it
and button event is like this
[cell.BtnRequest addTarget:self action:#selector(didTapButton:) forControlEvents:UIControlEventTouchUpInside];
and didtapbutton code is this
- (void)didTapButton:(id)sender {
WorkerDetailsVC *wvc=[self.storyboard instantiateViewControllerWithIdentifier:#"workerdetailsvc"];
NSIndexPath *indepath = [self.tblorderdata indexPathForCell:sender];
wvc.arrworkarrequest=[arrData objectAtIndex:indepath.row];
NSLog(#" arr send :%#", wvc.arrworkarrequest);
wvc.struserid = struserid;
[self.navigationController pushViewController:wvc animated:YES];
}
and on the next page i got the array arrworkarrequest and after the load all next page it will show error like this
2014-10-01 15:08:42.607 demo[2151:60b] -[__NSCFNumber length]: unrecognized selector sent to instance 0x911a860
2014-10-01 15:08:42.613 dmeo[2151:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0x911a860'
Your problem is that sender is of type UIButton not UITableViewCell so it's getting stuck in the [self.tblorderdata indexPathForCell:sender] because that method call expects a type of UITableViewCell.
You need to find the Cell that the button is in. You may be able to do this using a while loop (although it's a bit horrible). Something like:
id obj = sender;
while (![obj isKindOfClass:[UITableViewCell class]]) {
obj = [sender superview];
}
[self.tblorderdata indexPathForCell:obj];
This feels like it's abusing the view hierarchy though.
This happens if you compare the length of a string directly
for example
NSString *myString = #"2";
using this statement will generate the error
if(myString.length==2)

UIPickerView in SKScene

I want to design a level select scene in my game. What I want is a very abstract design which consists of a single UIPickerView that has the width of the screen and about 200 px in height.
The following is from LevelSelect.m , which is a subclass of SKScene
-(id)initWithSize:(CGSize)size{
if (self = [super initWithSize:size]) {
/* Setup your scene here */
self.backgroundColor = [SKColor whiteColor];
for (int i = 0; i < 10; i++) {
NSString* levelString = [NSString stringWithFormat:#"Level %i",i];
[levelData setObject:levelString atIndexedSubscript:i];
}
UIPickerView *levelPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(self.scene.size.width/2, self.scene.size.height/2, self.scene.size.width, 200)];
levelPickerView.dataSource = self;
levelPickerView.delegate = self;
levelPickerView.showsSelectionIndicator = YES;
[self addChild:levelPickerView];
}
return self;
}
I implemented the UIPickerView data source and delegate methods. But when i load the scene i get the following error .
2014-07-23 22:32:41.222 Poppolo[13686:60b] -[UIPickerView setPaused:]: unrecognized selector sent to instance 0x17d90470
2014-07-23 22:32:41.225 Poppolo[13686:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPickerView setPaused:]: unrecognized selector sent to instance 0x17d90470'
* First throw call stack:
(0x2dd30f0b 0x384c7ce7 0x2dd34837 0x2dd33137 0x2dc82098 0x304618cb 0xe1f3d 0xe70fb 0x389b0d53 0x389b0d3f 0x389b36c3 0x2dcfb681 0x2dcf9f4d 0x2dc64769 0x2dc6454b 0x32bd16d3 0x305c3891 0xee221 0x389c5ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
thanks in advance.

Getting Error setting Title for the UIButton

Im attempting to make the title of a UIButton the favorites count of the particular tweet from twitter. I can functionally attain the number and I am successfully authorized with Twitter. Here is how I am attempting to set the Title:
//Set number of Favorites for Tweet
NSObject *favoritesCount = [[tweet objectForKey:#"user"]objectForKey:#"favourites_count"];
UIButton *favoritesButton = (UIButton *)[cell viewWithTag:204];
favoritesButton.titleLabel.text = favoritesCount;
When I run this I get the error at favoritesButton.titleLabel.text = favoritesCount;
Here is the error I am getting:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0x8d3a3a0'
Title should be NSString value. You need to set title as NSString not NSObject.
NSInteger favoritesCount = [[tweet objectForKey:#"user"]objectForKey:#"favourites_count"];
UIButton *favoritesButton = (UIButton *)[cell viewWithTag:204];
favoritesButton.titleLabel.text = [NSString stringWithFormat:#"%d",favoritesCount];

How to unload previous level (class) in iOS

In my game, when I load a new level, the previous level seems to be still remaining in the view.. Each level has its own class and they all draw something on the screen. So if I have 2 or more levels of images loaded, that makes my game too slow. What can I do to unload the previous level? Thanks in advance..
- (void) finishedLevel: (Level *) level
{
levelNumber++;
levelClass = NSClassFromString([NSString stringWithFormat:
#"Level_%d", levelNumber]);
if (!levelClass) levelClass = [Level class];
currentLevel = [[levelClass alloc] initWithView: self.mainView];
self.mainView.levelLabel.text = [NSString stringWithFormat:#"Level %d", levelNumber];
gameRunning = NO;
}
I tried using the following but didn't really work
levelClass = NSClassFromString([NSString stringWithFormat:#"Level_%d", levelNumber-1]);
[levelClass removeFromSuperview];
Error message
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[Level_1 removeFromSuperview]: unrecognized selector sent to class 0x107644'

Resources