Updated the iOS Objective-C code to use NSDictionary/NSArray/NSNumber literals and subscripting, for improved code clarity.

This requires at least Xcode 4.5 and the iOS 6 SDK to build, but it doesn't change the minimum supported runtime version (iOS 5.1). Less than 2% of iOS users are running iOS 5, so I hope developers aren't trying to build SDL using an SDK which doesn't support iOS 6/7...
main
Alex Szpakowski 2014-07-23 01:28:24 -03:00
parent 078ca9f078
commit 967549c9ad
6 changed files with 12 additions and 28 deletions

View File

@ -53,7 +53,7 @@ static SDL_bool s_showingMessageBox = SDL_FALSE;
return self;
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
*clickedButtonIndex = (int)buttonIndex;
}
@ -77,8 +77,8 @@ UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
@autoreleasepool {
UIAlertView* alert = [[UIAlertView alloc] init];
alert.title = [NSString stringWithUTF8String:messageboxdata->title];
alert.message = [NSString stringWithUTF8String:messageboxdata->message];
alert.title = @(messageboxdata->title);
alert.message = @(messageboxdata->message);
alert.delegate = [[UIKit_UIAlertViewDelegate alloc] initWithButtonIndex:&clicked];
for (i = 0; i < messageboxdata->numbuttons; ++i) {

View File

@ -94,10 +94,10 @@
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
eaglLayer.opaque = YES;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking,
colorFormat, kEAGLDrawablePropertyColorFormat,
nil];
eaglLayer.drawableProperties = @{
kEAGLDrawablePropertyRetainedBacking: @(retained),
kEAGLDrawablePropertyColorFormat: colorFormat
};
/* Set the appropriate scale (for retina display support) */
self.contentScaleFactor = scale;

View File

@ -25,20 +25,6 @@
#include "../SDL_sysvideo.h"
#ifndef __IPHONE_6_0
/* This enum isn't available in older SDKs, but we use it for our own purposes on iOS 5.1 and for the system on iOS 6.0 */
enum UIInterfaceOrientationMask
{
UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait),
UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft),
UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight),
UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown),
UIInterfaceOrientationMaskLandscape = (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
UIInterfaceOrientationMaskAll = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown),
UIInterfaceOrientationMaskAllButUpsideDown = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
};
#endif /* !__IPHONE_6_0 */
#endif /* _SDL_uikitvideo_h */

View File

@ -61,9 +61,9 @@
- (void)showKeyboard;
- (void)hideKeyboard;
- (void)initializeKeyboard;
@property (readonly) BOOL keyboardVisible;
@property (nonatomic,assign) SDL_Rect textInputRect;
@property (nonatomic,assign) int keyboardHeight;
@property (nonatomic, readonly) BOOL keyboardVisible;
@property (nonatomic, assign) SDL_Rect textInputRect;
@property (nonatomic, assign) int keyboardHeight;
SDL_bool UIKit_HasScreenKeyboardSupport(_THIS);
void UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window);

View File

@ -395,7 +395,7 @@ void _uikit_keyboard_init() {
queue:queue
usingBlock:^(NSNotification *notification) {
int height = 0;
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
CGSize keyboardSize = [[notification userInfo][UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
height = keyboardSize.height;
UIInterfaceOrientation ui_orient = [[UIApplication sharedApplication] statusBarOrientation];
if (ui_orient == UIInterfaceOrientationLandscapeRight || ui_orient == UIInterfaceOrientationLandscapeLeft) {

View File

@ -70,9 +70,7 @@
const char *orientationsHint = SDL_GetHint(SDL_HINT_ORIENTATIONS);
if (orientationsHint != NULL) {
NSString *orientationsString = [NSString stringWithCString:orientationsHint
encoding:NSUTF8StringEncoding];
NSArray *orientations = [orientationsString componentsSeparatedByCharactersInSet:
NSArray *orientations = [@(orientationsHint) componentsSeparatedByCharactersInSet:
[NSCharacterSet characterSetWithCharactersInString:@" "]];
if ([orientations containsObject:@"LandscapeLeft"]) {