Skip to content

Instantly share code, notes, and snippets.

View vikdenic's full-sized avatar

vik vikdenic

  • Chicago, IL
View GitHub Profile
@vikdenic
vikdenic / gist:724b92e87de256fe9e2c
Created October 22, 2014 03:14
cloud function for phone number
let phoneDictionary = ["phoneNumber" : rider.phoneNumber]
PFCloud.callFunctionInBackground("DriverApproaching", withParameters: phoneDictionary) { (result, error) -> Void in
if error != nil
{
println("DriverApproaching succeeded")
}
}
@vikdenic
vikdenic / gist:7b1f5cbef5c34650e621
Created October 22, 2014 03:49
cancel function
https://gist.github.com/vikdenic/ad3ec02e41fca673f66e
@vikdenic
vikdenic / gist:30f01c4b01ce88524c47
Created October 22, 2014 03:49
cancel function
let infoDictionary = ["user_id" : profile.objectId]
PFCloud.callFunctionInBackground("CancelRide", withParameters: infoDictionary) { (result, error) -> Void in
if error != nil
{
println("CancelRide succeeded")
}
}
@vikdenic
vikdenic / gist:8412151e972564f91fc7
Created October 23, 2014 02:21
UIAlertController
var alert : UIAlertController = UIAlertController(title: title,
message: message, preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "Nevermind", style:.Default, handler: nil))
let confirmButton = UIAlertAction(title: "Cancel Ride", style: .Default) { (action) -> Void in
self.setViewsOnCanceledRide()
}
alert.addAction(confirmButton)
@vikdenic
vikdenic / gist:a2d6d4ee53f583ad49c8
Created October 24, 2014 16:13
Fridge Rules Example
// Playground - noun: a place where people can play
import UIKit
class FoodItem {
var labeled : Bool!
var daysOld : Int!
convenience init (labeled isLabeled: Bool!, daysOld age: Int)
{
class func queryForComments(theStudent: Dossier, completed: (comments: [Comment], error: NSError!) -> Void)
{
let query = Comment.query()
query.includeKey("commenter")
query.whereKey(kStudentKeyString, equalTo: theStudent)
query.orderByAscending("createdAt")
query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
if error == nil
{
let url : NSURL = NSBundle.mainBundle().URLForResource("typingLogin", withExtension: "gif")!
self.backgroundImageView.image = UIImage.animatedImageWithAnimatedGIFURL(url)
@vikdenic
vikdenic / gist:b1f4212472b2f9ce9aa2
Created December 12, 2014 22:48
UITabBar icon colors
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.customNotQuiteWhite()], forState:.Normal)
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.customPinkColor()], forState:.Selected)
@vikdenic
vikdenic / gist:be124793edb1f5a405c2
Created December 22, 2014 03:58
For-In Loop example
NSArray *carsArray = [[NSArray alloc] initWithObjects:@"Tesla", @"BMW", @"Audi", @"VW", nil];
for (NSString *car in carsArray)
{
NSLog(@"%@", car);
}
@vikdenic
vikdenic / gist:b4753888e961e5f3c008
Created December 22, 2014 22:16
Swift / Tests Target Array Workaround
func testBartenderQueryForGivenEvent()
{
let expectation = self.expectationWithDescription("Wait for the bartender to be retrieved")
Venue.queryForTestVenue { (venue, error) -> Void in
let testVenue = venue as Venue
testVenue.bartenders { (bartenders, error) -> Void in
//NOTE: This casting is a workaround for an issue with Arrays in the Tests target