Skip to content

Instantly share code, notes, and snippets.

@burhanaksendir
burhanaksendir / gist:8544fbe00598a1e8d7a4
Created December 14, 2014 21:11
Flex Mobile Spark List View
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
creationComplete="view1_creationCompleteHandler(event)" xmlns:views="views.*"
>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
[Bindable]
@burhanaksendir
burhanaksendir / gist:4832b818cd1a08181220
Created December 14, 2014 21:13
Flex Mobile : CheckBox iconItemRenderer
<?xml version="1.0" encoding="utf-8"?>
<s:IconItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Metadata>
[Event(name="checkBoxIconItemRendererChanged", type="flash.events.Event")]
</fx:Metadata>
<fx:Script>
<![CDATA[
import spark.components.CheckBox;
@burhanaksendir
burhanaksendir / gist:ab01fbe778e519532bff
Created May 27, 2015 12:07
SplashScreen animation in Swift
//
// SplashViewController.swift
// splashAnimation
//
// Created by Burhan Aksendir on 26.03.2015.
// Copyright (c) 2015 Aksendir. All rights reserved.
//
import UIKit
@IBAction func shareFacebook(sender: AnyObject) {
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook){
var facebookSheet: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
facebookSheet.setInitialText("Demo")
self.presentViewController(facebookSheet, animated: true, completion: nil)
} else {
//declare closure outsize class definition (above class definition)
typealias CompletionHandler = (success:Bool!) -> Void
//declare library variable inside class
var library:ALAssetsLibrary?
//initialize variable in viewDidLoad
library = ALAssetsLibrary();
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Parse initialization
Parse.setApplicationId(“xxxxxxxxxxxxxxxx", clientKey: “xxxxxxxxxxxxx")
let types = UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound
let settings = UIUserNotificationSettings(forTypes: types, categories: nil)
application.registerUserNotificationSettings(settings)
return true
@burhanaksendir
burhanaksendir / gist:2e84877396670533a5ba
Last active August 29, 2015 14:23
Main View Controller
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: "remoteNotificationReceiveAction:", name: "remoteNotificationReceived", object: nil)
}
func remoteNotificationReceiveAction(data: NSNotification) {
if let apsPayloadContent: AnyObject = data.userInfo as? AnyObject {
@burhanaksendir
burhanaksendir / remoteFileExists
Created June 23, 2015 02:31
How to check if a remote file exists in Swift ?
func remoteFileExists(url: String) -> Bool {
var exists: Bool = false
let url: NSURL = NSURL(string: url)!
var request: NSMutableURLRequest = NSMutableURLRequest(URL: url)
request.HTTPMethod = "HEAD"
var response: NSURLResponse?
NSURLConnection.sendSynchronousRequest(request, returningResponse: &response , error: nil)
class BookViewController: UIViewController {
var book: UIView!
var content: NSMutableArray!
var currentPage: Int = 0
var font: UIFont!
override func viewDidLoad() {
@burhanaksendir
burhanaksendir / gist:216c446f03b09fa1e27d
Created July 8, 2015 21:09
iOS - UIBarButtonItem Settings Gear
let gearTitle = NSString(string: "\u{2699}") as String
let fontStyle = [NSFontAttributeName: UIFont(name: "Avenir Next", size: 27)!]
let settingsButton = UIBarButtonItem(title: gearTitle, style: UIBarButtonItemStyle.Plain, target: self, action: Selector("showSettingsVC:"))
settingsButton.setTitleTextAttributes(fontStyle, forState: UIControlState.Normal)