Skip to content

Instantly share code, notes, and snippets.

// Note this snippet requires AFNetworking v2.x
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.securityPolicy.allowInvalidCertificates = YES;
manager.requestSerializer = [AFJSONRequestSerializer serializer];
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
result[@"username"] = @"JohnSmith";
result[@"email"] = @"john@msith.com";
result[@"phone"] = @"06543213131";
result[@"name"] = @"John Smith";
// assumes object class called SENQuestionnaire
- (void)writeDictionaryToDisk:(SENQuestionnaire *)q
{
NSDictionary *dataDictionary =
@{
@"stringA" : @"string A",
@"stringB" : @"string B",
@"stringC" : @"string C",
- (PdAudioStatus)configurePlaybackWithSampleRate:(int)sampleRate
numberChannels:(int)numChannels
inputEnabled:(BOOL)inputEnabled
mixingEnabled:(BOOL)mixingEnabled
ambientEnabled:(BOOL)ambientEnabled {
PdAudioStatus status = PdAudioOK;
if (inputEnabled && ![[AVAudioSession sharedInstance] inputIsAvailable]) {
inputEnabled = NO;
status |= PdAudioPropertyChanged;
//
// CCHelper.h
// jason-wednesday
//
// Created by codeCamp on 9/07/2014.
// Copyright (c) 2014 codeCamp. All rights reserved.
//
#import <Foundation/Foundation.h>
//
// CCHelper.m
// jason-wednesday
//
// Created by codeCamp on 9/07/2014.
// Copyright (c) 2014 codeCamp. All rights reserved.
//
#import "CCHelper.h"
- (CGRect)makeFrameForButton:(UIButton*)button
{
int randomHeightInt = roundf(self.view.frame.size.height - self.hitMeButton.frame.size.height)-50;
int randomWidthInt = roundf(self.view.frame.size.width - self.hitMeButton.frame.size.width) - 20;
int randomHeight = arc4random() %randomHeightInt + 50;
int randomWidth = arc4random() % randomWidthInt + 20;
CGRect frame = CGRectMake(randomWidth,
randomHeight,
button.frame.size.width,
#import "CCViewController.h"
@interface CCViewController ()
{
int score,lives,highScore,timeLeft;
BOOL playing;
}
@property (weak, nonatomic) IBOutlet UIButton *hitMeButton;
@property (weak, nonatomic) IBOutlet UIButton *loseLifeButton;
- (void)viewDidLoad
{
[super viewDidLoad];
// do any additional...
UITapGestureRecognizer *gestureRecogniser =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(handleTap:)];
gestureRecogniser.numberOfTapsRequired = 1;
- (void)endGame
{
if (playing) {
playing = NO;
[self hideButton];
[self.playPauseButton setTitle:@"Play" forState:UIControlStateNormal];
if (score > highScore) {
highScore = score;
- (void)handleTap:(UIGestureRecognizer*)tap {
if (playing) {
// score--;
[self updateLabels];
if (score < 0) {
[self endGame];
}
}
}