-(id) 就是 Objective-C 中的 object, 本身就是帶一個 pointer 所以不用再加 *
-(id)initWithName:(NNString *)name andAge:(int)age{
id result = [super init];
if(result){
self.name = name;
self.age = age;
var url = NSURL(string: "http://www.stackoverflow.com")
var request = NSURLRequest(URL: url)
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue(), completionHandler: {(response: NSURLResponse!, data: NSData!, error: NSError!) in
println(NSString(data: data, encoding: NSUTF8StringEncoding))
override func viewWillDisappear(animated:Bool) { | |
if let currentViewControllers = self.navigationController.viewControllers as? [UIViewController] { | |
if let found = find(currentViewControllers, self) { | |
// Do nothing if the current controller is still in the stack. This means we're going forward, not back | |
} | |
else { | |
self.performSegueWithIdentifier("unwindToLogin", sender:self) | |
} | |
} | |
super.viewWillDisappear(animated) |
#!/bin/sh | |
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal | |
# make sure the output directory exists | |
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" | |
# Step 1. Build Device and Simulator versions | |
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build | |
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build |
// | |
// parkingDate.swift | |
// stopTest | |
// | |
// Created by Laibit on 2015/7/28. | |
// Copyright (c) 2015年 Laibit. All rights reserved. | |
// | |
import UIKit |
// Release under MIT | |
// Copyright (C) 2015 Xaree Lee | |
#import <Foundation/Foundation.h> | |
/* Get property name for the class (C string or NSSting). */ | |
#define keypathForClass(Klass, PropertyName) \ | |
(((void)(NO && ((void)[Klass _nullObjectForCheckingPropertyName].PropertyName, NO)), # PropertyName)) | |
#define keypathStringForClass(Klass, PropertyName) \ | |
@keypathForClass(Klass, PropertyName) |
#!/usr/bin/env swift | |
import Foundation | |
func oneLoop() -> Double{ | |
var sumValue = 0 | |
let startTime = NSDate().timeIntervalSince1970 | |
for i in 1...100000000 { | |
if (i % 2 == 1) { | |
sumValue++ | |
} else { |
NSOperationQueue *queue = [[NSOperationQueue alloc] init]; | |
queue.maxConcurrentOperationCount = 1; | |
NSInteger inputValue = 5; | |
NSMutableArray<NSOperation *> *operations = [NSMutableArray<NSOperation *> array]; | |
for (NSInteger i=0; i<inputValue; i++){ | |
NSOperation *operation = [NSBlockOperation blockOperationWithBlock:^{ | |
NSLog(@".Running operation %d", i); | |
[NSThread sleepForTimeInterval:1]; | |
}]; |