Skip to content

Instantly share code, notes, and snippets.

func ImageUpload(UrlString:String,ImageParams:Dictionary<String, String>,ImageData:NSData,ReqToVar:String){
//增加 group 的進入次數,group同上方宣告的group
dispach_group_enter(group)
var urlRequest = urlRequestWithComponents(UrlString, parameters: ImageParams, imageData: ImageData)
var FileUrl:JSON!
Alamofire.upload(urlRequest.0, urlRequest.1)
.progress { (bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) in
// println("\(totalBytesWritten) / \(totalBytesExpectedToWrite)")
}
@gradyzhuo
gradyzhuo / gist:be9b5f32fbc14b86ef7d
Last active August 29, 2015 14:27
parkingData
//
// parkingDate.swift
// stopTest
//
// Created by Laibit on 2015/7/28.
// Copyright (c) 2015年 Laibit. All rights reserved.
//
import UIKit
@gradyzhuo
gradyzhuo / main.m
Created September 6, 2015 05:13
MatrixDemoByBLAS - Accelerate Framework
//
// main.m
// Matrix
//
// Created by Grady Zhuo on 2015/9/6.
// Copyright © 2015年 Grady Zhuo. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Accelerate/Accelerate.h>
@gradyzhuo
gradyzhuo / RunUnitTests.sh
Created October 28, 2015 06:16 — forked from mbinna/RunUnitTests.sh
Run Xcode Application Tests from the command line
#!/bin/sh
# Launch application using ios-sim and set up environment to inject test bundle into application
# Source: http://stackoverflow.com/a/12682617/504494
if [ "$RUN_APPLICATION_TESTS_WITH_IOS_SIM" = "YES" ]; then
test_bundle_path="$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.$WRAPPER_EXTENSION"
environment_args="--setenv DYLD_INSERT_LIBRARIES=/../../Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection --setenv XCInjectBundle=$test_bundle_path --setenv XCInjectBundleInto=$TEST_HOST"
ios-sim launch $(dirname $TEST_HOST) $environment_args --args -SenTest All $test_bundle_path
echo "Finished running tests with ios-sim"
func doAsyncAction(completionHandler:(callback:AnyObject)->Void){
let delay = Int64(NSEC_PER_MSEC*100)
let afterTime = dispatch_time(DISPATCH_TIME_NOW, delay)
let queue = dispatch_get_global_queue(0, 0)
//等待100毫秒(0.1秒)後再執行
dispatch_after(afterTime, queue) { () -> Void in
completionHandler(callback: "Hello world")
}
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];
}];