Crash when setting attributes dictionary of UIBarButtonItem - objective-c

I have the following code:
UIFont * applicationBolFontOfSize26=[fontsSuperclass returnApplicationMainFontOfSize:26.0f];
[self.settingsButton setTitleTextAttributes:#{ NSFontAttributeName : applicationBolFontOfSize26 } forState:UIControlStateNormal];
where font superclass method is defined as:
+(UIFont *)returnApplicationMainFontOfSize:(CGFloat)floatSize {
return [UIFont fontWithName:#"HelveticaNeue-Regular" size:floatSize];
}
but the self.settingButton setTitleText... crashes with error:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
Why?

There is no font named "HelveticaNeue-Regular" so your font is nil. Use [UIFont fontWithName:#"HelveticaNeue" size:floatSize] for the regular Helvetica Neue font.

Related

why crash this code at boundingRectWithSize?

- (CGSize)sizeOfLabel:(UILabel *)label withText:(NSString *)text {
CGSize maximumLabelSize = CGSizeMake(308,9999);
UIFont *font=[UIFont systemFontOfSize:14];
CGRect textRect = [text boundingRectWithSize:maximumLabelSize options:NSStringDrawingUsesLineFragmentOrigin attributes:#{NSFontAttributeName:font} context:nil]; // CRASH HERE
return textRect.size;
}
**the error message is:**
2014-06-16 14:55:07.783 OrgBeac[2931:60b] -[Message boundingRectWithSize:options:attributes:context:]: unrecognized selector sent to instance 0x17557a70
2014-06-16 14:55:07.787 OrgBeac[2931:60b] \*\*\* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Message boundingRectWithSize:options:attributes:context:]: unrecognized selector sent to instance 0x17557a70'
\*\*\* First throw call stack:
(0x2e6f4fd3 0x38f6dccf 0x2e6f8967 0x2e6f7253 0x2e6f84f8 0x575d5 0x579e7 0x31020a2b 0x30fe569f 0x30fe73fd 0x30fe7351 0x30fe6f45 0x56f37 0x2f0e56d1 0x39324cef 0x393222ad 0x39321319 0x2f0e3cb9 0x2f0e3f41 0x2f0e40b7 0x2f0e41b5 0x5674d 0x2f033fc3 0x2f033f07 0x2f033e21 0x2e35b0e7 0x2e359cf7 0x2e628941 0x2e2f16bb 0x2e2f1579 0x2e2f140d 0x2e6c025b 0x2e6bf72b 0x2e6bdf1f 0x2e628f0f 0x2e628cf3 0x33581663 0x30f7416d 0x55283 0x3947aab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
The object text that you are passing in needs to be an NSString but it is a Message object.
I'm guessing that wherever you are calling this from you are doing something like...
[someObject sizeOfLabel:myLabel withText:message];
When in fact what you meant is...
[someObject sizeOfLabel:myLabel withText:message.text];

What does internalconsistency mean?

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/C8CF9D6E-4B29-416B-8973-A6F18C0CE691/.app> (loaded)' with name 'BGCinemaScheduleCell''
*** First throw call stack:
(0x32d812a3 0x3aa2697f 0x32d811c5 0x34d26571 0x34d2e2b7 0x137e4d 0x13833f 0x1383fd 0x1b6b97 0x34dffdef 0x17218b 0x34bd454d 0x34bb9313 0x34bd07cf 0x34b8c803 0x34936d8b 0x34936929 0x3493785d 0x34937243 0x34937051 0x34936eb1 0x32d566cd 0x32d549c1 0x32d54d17 0x32cc7ebd 0x32cc7d49 0x3688b2eb 0x34bdd301 0xa1385 0x3ae5db20)
libc++abi.dylib: terminate called throwing an exception
Okay there is indeed an actual XIB named BGCinemaScheduleCell
I got this error here:
-(void) vLoadMainBundle
{
if ([self class] == [BGBaseTableViewCell class])
{
return;
}
NSString * className = NSStringFromClass([self class]);
[[NSBundle mainBundle] loadNibNamed:className owner:self options:nil];
}
I have no idea what NSInternalInconsistencyException mean. the value of className is loadNibNamed
It turns out the xib hasn't been copied to the bundle resources that an answer in https://stackoverflow.com/a/5646337/2027232 would work.
The next question would be why the xib isn't copied to the bundle resources when I created it.

assigning values in NSArrays

Objective C gives me a run-time error for the indicated line of code
-(void) play: (int)i at: (int)j {
if ([self.board[i][j] isEqualToString:#""]){
if (xplays) {
self.board[i][j] = #"x"; //<-----HERE
}
else
self.board[i][j] = #"x";
}
xplays = !xplays;
}
board is a property. The error message is
[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance 0x7123120
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance 0x7123120'
Do I need to use C-arrays for this kind of assignment?
You should be using an NSMutableArray.

KTPhotoBrowser push to KTTumbsViewController

I am trying to use KTPhotoBrowser to use its thumbnail view capabilities. I have some difficulties to push to the viewController that was derived from KTThumbsViewController. It seems the navigationController can only push to UIViewController:
- (void)showSDWebImageSample
{
KTThumbsViewController *newController = [[KTThumbsViewController alloc] init];
[self.navigationController pushViewController:newController animated:YES];
}
and the header file for KTThumbsViewController includes:
#interface KTThumbsViewController : UIViewController <KTThumbsViewDataSource>
I grabbed the code from the provided sample. But it gives me the following runtime error:
-[KTThumbsViewController copyWithZone:]: unrecognized selector sent to instance 0x8877130
2012-10-30 14:52:03.004 myCases_MD[36941:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[KTThumbsViewController copyWithZone:]: unrecognized selector sent to instance 0x8877130'
Could anyone help me please?
Cheers,

Error saving to iOS keychain using KeychainItemWrapper

I get an error every time I try to store data into the keychain
The error comes from the dictionaryToSecItemFormat method at these lines
NSString *passwordString = [dictionaryToConvert objectForKey:(id)kSecValueData];
[returnDictionary setObject:[passwordString dataUsingEncoding:NSUTF8StringEncoding] forKey:(id)kSecValueData]'
The error is
I'm calling the KeychainItemWrapper methods like this
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:#"credentials" accessGroup:nil];
[keychain setObject:username forKey:kSecAttrAccount];
[keychain release];
The error is
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[NSConcreteData dataUsingEncoding:]: unrecognized selector sent to instance"
dataUsingEncoding is a method from the NSString class, make username a NSString.