Deprecated error [duplicate] - objective-c

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
UIKeyboardBoundsUserInfoKey is deprecated, what to use instead?
I have the following code with an issue which I would love to remove:
NSDictionary* info = [notif userInfo];
NSValue* aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];
CGSize keyboardSize = [aValue CGRectValue].size;
On the second line of the code I get the message "UIKeyboardBoundsUserInfoKey is deprecated".
I,ve read similar error messages on the forum and tried a few things but my newby mind can not fix it.

You should check out the docs anytime something is marked as deprecated. You will usually find info about what has replaced the deprecated item. In this case, the Keyboard Notification User Info Keys section of the UIWindow reference:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html
Use UIKeyboardFrameBeginUserInfoKey and UIKeyboardFrameEndUserInfoKey instead of UIKeyboardBoundsUserInfoKey

it means that DONT USE UIKeyBoundsUserInfoKey. because it is not present anymore in the new iOS xcode... so try to use the later or different key..i.e look at this tutorial
http://www.w3bookmarks.com/mobile-application-development-tutorial/iphone-questions-uikeyboardboundsuserinfokey-is-deprecated-what-to-use-instead/

You can use UIKeyboardFrameEndUserInfoKey instead of UIKeyboardBoundsUserInfoKey.

Related

NSMutableArray removeObject: throwing an error [duplicate]

This question already has answers here:
Unrecognized selector when adding an object to NSMutableArray
(2 answers)
Closed 8 years ago.
I have an #property (nonatomic,copy) NSMutableArray* children;, and I'm adding/removing items to this array.
Here's the surprise:
- (void)addChildDocument:(PPDocument *)doc {
[_children addObject:doc];
}
- (void)removeChildDocument:(PPDocument*)doc {
[_children removeObject:doc];
}
The first one works fine. The second one doesn't.
-[__NSArrayI removeObject:]: unrecognized selector sent to instance
Can you please explain to me exactly what is going on and how the children array suddenly shows up as immutable?
UPDATE:
The issue has been resolved. However, as weird as it may strike you, the copy most of you referred to had nothing to do with the issue. Weirdly it had to do with a parent property of each PPDocument not being correctly set as weak. Once I did that (and leaving the children as it was), everything works fine - as expected. And NSMutableArrays remain mutable whatsoever.
You must be doing:
obj.children = #[ #"Some", #"immutable", #"array" ];
between those calls.
You can't remove what you're adding in the method. You need to give him an array index.
For example,
[_children removeObject:[_children lastObject]];
if you know that it's always gonna be the last one.
If its not, please provide a comment with more explanation on where the object can be.
Edit : actually you might be able to do the following, could you try too?
[_children removeObjectAtIndex:[_children indexOfObject:doc]];

Get text from NSTextField [duplicate]

This question already has answers here:
Get value from NSTextField
(4 answers)
Closed 8 years ago.
I'm new to OS X development in Xcode and was wondering how to get the text from a text field and NSLog it, I would also like to pass it to a string. Any help?
The -stringValue method can be used.
NSTextField *myTextField = [[NSTextField alloc] initWithFrame:...];
NSString *text = [myTextField stringValue];
NSLog(#"%#", text);
Do not be fooled by those who say that text is a property of NSTextField.
Before asking questions like this, please read up on the documentation here:NSTextView. Also please take a look at all of Apple's documentation here:Apple Documentation

use '[]' syntax to access containers in XCode 4.4 seems not working

Has anyone tried new syntax sugar introduced in Xcode 4.4 (iOS 5.1), like automatically calls #synthesize or Literal Syntax for NSArray ? They are quite handy.
But I can't get it right for this one , "use '[]' syntax to access". I tried following and they did not work. What did I do wrong ? Thanks.
NSArray *tmp = #[#"hello",#"world"]; //This one works fine
NSString *i = tmp[0]; // or tmp[#0]; this one does not work.
You're using two different features there. Your first line (tmp = #[#"hello",#"world"]) are literals. That should work in Xcode 4.4.
The second line (i = tmp[0]) needs runtime support (there are a couple of extra methods needed to make it work) and so won't work in iOS 5 and below. See this answer for more details.

Objective-C, Buzztouch coding alerts - Data argument not used by format string and Semantic issue. Can someone explain what is going on?

I'm currently running Mountain Lion OS X 10.8 with Xcode 4.4 installed. I'm running the iOS 5.1 simulator. I'm using Buzztouch as a learning tool while I'm studying Objective-C and Xcode. I get the following alerts when I compile, but the build succeeds. However, I would like to know exactly what is going on and how I can remedy the situation. Thank you for any assistance you can provide. Here's the code and the alerts I'm getting:
BT_fileManager.m
Data argument not used by format string
[BT_debugger showIt:self:[NSString stringWithFormat:#"readTextFileFromBundleWithEncoding ERROR using encoding NSUTF8StringEncoding, trying NSISOLatin1StringEncoding", #""]];
Data argument not used by format string
[BT_debugger showIt:self:[NSString stringWithFormat:#"readTextFileFromCacheWithEncoding ERROR using encoding NSUTF8StringEncoding, trying NSISOLatin1StringEncoding", #""]];
BT_camera_email.m
Semantic Issue
Sending 'BT_camera_email *' to parameter of incompatible type 'id'
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
NSLog(#"is camera ok");
UIActionSheet *photoSourceSheet = [[UIActionSheet alloc] initWithTitle:#"Select Image Source"
delegate:self
Again, thanks.
Greg
I have no idea what Buzztouch might be, however.... :-)
The first warning is fairly simple. In a format string there are placeholders beginning with a '%' sign to indicate where data values should be substituted. For example, to substitute a string, one would use '%#'. In the examples you show, there are no placeholders but there are data values -- empty strings. The compiler is warning that something you indicate you want to have put into the new string created by stringWithFormat: won't be.
To be sure about the second one, I'd want to see the .h file that declares BT_camera_email but my best guess is that it doesn't adopt the UIActionSheetDelegate protocol. The description of initWithTitle:... says the second parameter should be id<UIActionSheetDelegate> and that's probably what is being complained about.

NSString may not respond to EncryptAES- Xcode Warning

It seems like I have the correct code, and it compiles, runs, and builds. BUT it does not carry out certain lines of code because of the following error: "NSString may not respond to EncryptAES"
The code where the warning occurs is contained below:
- (IBAction)Encrypt {
//Change the Input String to Data
NSData *objNSData = [NSData dataWithData:[Input dataUsingEncoding: NSUTF8StringEncoding]];
//Encrypt the Data
objNSData = [Input EncryptAES:Keyword.text]; //Line with Warning
I have searched StackOverflow for problems like this and figured that to cure this error I should use some sort of code like this in my header file:
#interface  NSString
-(NSString*)AESEncrypt:????
#end
Would this fix the warning? If so, then what do I put where the questions go?
If this code will not fix the problem then what do I do to get rid of this error and make the code function?
EDIT: I have also tried this using NSData, I get the same resulting warning
You're calling EncryptAES class method against "Input" which based on your comment and code above ([Input dataUsingEncoding...) appears to be an NSString.
NSString does not offer an EncryptAES method:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html
Checkout these SO posts:
AES Encryption for an NSString on the iPhone
uses: http://pastie.org/426530
iPhone - AES256 Encryption Using Built In Library
See here. Apparently EncryptAES is a "category" for NSData. I doubt that it will work on an NSString.