Skip to content

Instantly share code, notes, and snippets.

View post new customer snippet
// 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";
View save plist method
// assumes object class called SENQuestionnaire
- (void)writeDictionaryToDisk:(SENQuestionnaire *)q
{
NSDictionary *dataDictionary =
@{
@"stringA" : @"string A",
@"stringB" : @"string B",
@"stringC" : @"string C",
View Modified PDAudioController.m
- (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;
View CCHelper.h
//
// CCHelper.h
// jason-wednesday
//
// Created by codeCamp on 9/07/2014.
// Copyright (c) 2014 codeCamp. All rights reserved.
//
#import <Foundation/Foundation.h>
View CCHelper.m
//
// CCHelper.m
// jason-wednesday
//
// Created by codeCamp on 9/07/2014.
// Copyright (c) 2014 codeCamp. All rights reserved.
//
#import "CCHelper.h"
View makeRectForButton
- (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,
View CCViewController
#import "CCViewController.h"
@interface CCViewController ()
{
int score,lives,highScore,timeLeft;
BOOL playing;
}
@property (weak, nonatomic) IBOutlet UIButton *hitMeButton;
@property (weak, nonatomic) IBOutlet UIButton *loseLifeButton;
View viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
// do any additional...
UITapGestureRecognizer *gestureRecogniser =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(handleTap:)];
gestureRecogniser.numberOfTapsRequired = 1;
View endGame
- (void)endGame
{
if (playing) {
playing = NO;
[self hideButton];
[self.playPauseButton setTitle:@"Play" forState:UIControlStateNormal];
if (score > highScore) {
highScore = score;
View handleTap
- (void)handleTap:(UIGestureRecognizer*)tap {
if (playing) {
// score--;
[self updateLabels];
if (score < 0) {
[self endGame];
}
}
}
You can’t perform that action at this time.