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 resetGame
- (void)resetGame
{
score = 0;
lives = 3;
timeLeft = 30;
}
View countDown
- (void)countDown
{
if (playing) {
timeLeft --;
if (timeLeft == 0) {
[self endGame];
}
}
[self updateLabels];
}
View updateLabels
- (void)updateLabels
{
self.highScoreLabel.text =
[NSString stringWithFormat:@"High Score: %d",highScore];
self.scoreLabel.text =
[NSString stringWithFormat:@"Score: %d",score];
self.livesLabel.text =
[NSString stringWithFormat:@"Lives: %d",lives];
View pressResetButton
- (IBAction)pressResetButton:(UIButton *)sender {
if (!playing) {
highScore = 0;
score = 0;
[[NSUserDefaults standardUserDefaults]
setObject:[NSNumber numberWithInt:highScore]
forKey:@"highScore"];
}
[self updateLabels];
}
View hideButton
- (void)hideButton {
self.hitMeButton.hidden = TRUE;
self.loseLifeButton.hidden = TRUE;
self.addTimeButton.hidden = TRUE;
}
You can’t perform that action at this time.