NSURLSession
: OS の NSURLSession Daemon とのコネクションを管理するインスタンス。大体アプリにつき一つ。Singleton で OK. Delegate はこいつに紐づく。NSURLSessionTask
: 「リクエスト一つ」に対応。ただし OS 直属の NSURLSession Daemon に管理が委ねられる。
NSURLSession
を初期化
#include "HelloWorldScene.h" | |
#include "SimpleAudioEngine.h" | |
using namespace cocos2d; | |
using namespace CocosDenshion; | |
using namespace std; | |
CCScene* HelloWorld::scene() | |
{ | |
CCScene* scene = CCScene::create(); |
#ifdef DEBUG | |
#import "UIViewController+ClassNameOverlay.h" | |
#endif |
\lstdefinelanguage{swift} | |
{ | |
morekeywords={ | |
func,if,then,else,for,in,while,do,switch,case,default,where,break,continue,fallthrough,return, | |
typealias,struct,class,enum,protocol,var,func,let,get,set,willSet,didSet,inout,init,deinit,extension, | |
subscript,prefix,operator,infix,postfix,precedence,associativity,left,right,none,convenience,dynamic, | |
final,lazy,mutating,nonmutating,optional,override,required,static,unowned,safe,weak,internal, | |
private,public,is,as,self,unsafe,dynamicType,true,false,nil,Type,Protocol, | |
}, | |
morecomment=[l]{//}, % l is for line comment |
class TranslucentWin:NSWindow, NSApplicationDelegate, NSWindowDelegate{ | |
/** | |
* | |
*/ | |
override init(contentRect: NSRect, styleMask aStyle: Int, backing bufferingType: NSBackingStoreType, `defer` flag: Bool) { | |
super.init(contentRect: Win.sizeRect, styleMask: NSTitledWindowMask|NSResizableWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask|NSFullSizeContentViewWindowMask, backing: NSBackingStoreType.Buffered, `defer`: false) | |
self.contentView!.wantsLayer = true;/*this can and is set in the view*/ | |
self.backgroundColor = NSColor.greenColor().alpha(0.2) | |
self.opaque = false | |
self.makeKeyAndOrderFront(nil)//moves the window to the front |
//: Playground - noun: a place where people can play | |
import Cocoa | |
enum Enum { | |
case SimpleCase | |
case AssociatedValue(String) | |
case AnotherAssociated(Int) | |
} | |
extension Enum { |
Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.
This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.
URLSession.shared.rx | |
.response(imageURL) | |
// subscribe on main thread | |
.subscribeOn(MainScheduler.sharedInstance) | |
.subscribe(onNext: { [weak self] data in | |
// Update Image | |
self?.imageView.image = UIImage(data: data) | |
}, onError: { | |
// Log error | |
}, onCompleted: { |
関連: RFC 2394
//------------------------------------------------------------------------ | |
// The SwiftUI Lab: Advanced SwiftUI Animations | |
// https://swiftui-lab.com/swiftui-animations-part1 (Animating Paths) | |
// https://swiftui-lab.com/swiftui-animations-part2 (GeometryEffect) | |
// https://swiftui-lab.com/swiftui-animations-part3 (AnimatableModifier) | |
//------------------------------------------------------------------------ | |
import SwiftUI | |
struct ContentView: View { | |