Skip to content

Commit

Permalink
Updated the iOS Objective-C code to use NSDictionary/NSArray/NSNumber…
Browse files Browse the repository at this point in the history
… 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...
  • Loading branch information
slime73 committed Jul 23, 2014
1 parent 078ca9f commit 967549c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 28 deletions.
6 changes: 3 additions & 3 deletions src/video/uikit/SDL_uikitmessagebox.m
Expand Up @@ -53,7 +53,7 @@ - (id)initWithButtonIndex:(int *)buttonIndex
return self;
}

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
*clickedButtonIndex = (int)buttonIndex;
}
Expand All @@ -77,8 +77,8 @@ - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)
@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) {
Expand Down
8 changes: 4 additions & 4 deletions src/video/uikit/SDL_uikitopenglview.m
Expand Up @@ -94,10 +94,10 @@ - (id)initWithFrame:(CGRect)frame
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;
Expand Down
14 changes: 0 additions & 14 deletions src/video/uikit/SDL_uikitvideo.h
Expand Up @@ -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 */

Expand Down
6 changes: 3 additions & 3 deletions src/video/uikit/SDL_uikitview.h
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/video/uikit/SDL_uikitview.m
Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions src/video/uikit/SDL_uikitviewcontroller.m
Expand Up @@ -70,9 +70,7 @@ - (NSUInteger)supportedInterfaceOrientations
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"]) {
Expand Down

0 comments on commit 967549c

Please sign in to comment.