-(Move)generateMove { NSUInteger randomNumber = arc4random_uniform(3); swtich(randomNumber){ case 0: return Rock; break; case 1: return Paper; break; case 3: return Scissors; break; default: return Invalid; break; } // placeholder return Rock; }
-(BOOL)defeats:(RPSTurn *)opponent { if ((self.move == Paper && opponent.move == Rock) || (self.move == Scissors && opponent.move == Papper) || (self.move == Rock && opponent.move == Scissors)) { return true; } else { return false; } }
Present Video Camera
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) NSMutableArray *gifs; @end #import "UIViewController+Record.h" #import "GifEditorViewController.h" #import <MobileCoreServices/MobileCoreServices.h> #import <AVFoundation/AVFoundation.h> #import "GifMaker_Objc-Swift.h" @implementation UIViewController (Record) static int constt kFrameCount = 16; static const float kDelayTime = 0.2; static const int kLoopCount = 0; - (IBAction)presentVideoOptions:(id)sender { if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { [self launchPhotoLibrary]; } else { UIAlertController *newGifActionSheet = [UIAlertController alertControllerWithTitle:@"Create new GIF"] } } @implementation UIViewController (Record) static int const kFrameCount = 16; static const float kDelayTime = 0.2; static const int kLoopCount = 0; - (IBAction)presentVideoOptions:(id)sender{ if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { [self launchPhotoLibrary]; } else { UIAlertController *newGifActionSheet = [UIAlertController alertControllerWithTitle:@"Create new GIF" message:nil preferredStyle: UIAlertControllerStyleActionSheet]; UIAlertAction *recordVideo = [UIAlertAction actionWithTitle:@"Record a Video" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){ [self launchCamera]; }]; }