- afinfo: Audio Format Information, 查看音樂檔案相關內容, 包含 sampling rate, data rate, estimation duration
- afconvert: Audio Format Convert, 音樂轉檔功能, 常用選項(option), -b: 指定輸出 bit rate, -f: format
- afplay: 利用 command line來播放音樂
2013年2月2日 星期六
[Mac] Audio Format Utility
在 Mac上若想要查看或編輯音樂檔案, 可使用音樂相關工具程式 (prefix af: Audio Format)
2013年1月29日 星期二
[iOS] 一些 iOS 6過時的 API
dismissModalViewControllerAnimated
presentModalViewController
等皆將 Modal 字眼移除, 並在其後加 completion:nil
Ref: A lot of functions are deprecated in iOS 6
presentModalViewController
等皆將 Modal 字眼移除, 並在其後加 completion:nil
Ref: A lot of functions are deprecated in iOS 6
2013年1月28日 星期一
[iOS] NSInvalidUnarchiveOperationException Could not instantiate class named MKMapView
忘了把 MapKit framework加進來的後果....蠢到爆...
Project-> Build Phases-> Link Binary With Libraies-> + -> search "MapKit"
Project-> Build Phases-> Link Binary With Libraies-> + -> search "MapKit"
[iOS] autoreleasepool in iOS6 automated reference count
- iOS 6之前, 像是 multi-thread的環境, 需要自己管理記憶體, 通常會看到如下的程式片段
- NSAutoreleasePool *pool = [[NSAutoreleasedPool alloc] init];
- .....
- [pool drain];
- iOS 6之後, 在 ARC的環境下, 只要頭尾以 @autoreleasepool{ ...} 包起來即可
- Ref:
[iOS] Update Locations
- iOS 6建議使用 didUpdateLocations, 而非 didUpdateToLocation
- iOS6之前
- Controller 繼承 protocol <CLLocationManagerDelegate>
- e.g. FirstViewController : UIViewController <CCLocationManagerDelegate>
- 宣告一個 CLLocationManger 的 property並在 .m中 synthesize
- e.g. @property (nonatomic, retain) CLLocationManager *locationManager;
- 實作 didUpdateToLocation: (CLLocation *) newLocation fromLocation: (CLLocation *)
- e.g. 通常會將 outlet的 View其內容作設定
- e.g. locationTextView.text = [NSString stringWithFormat: @"lat %+6.f", newLocation.coordination.latitude];
- 改為覆寫 didUpdateLocations: (NSArray *) locations
- 並用 [locations lastObject]來取用最新位置
- Ref:
2012年11月2日 星期五
[iOS] iOS: import, property, protocol
- 用 #import來加入 package, import與 include最大的差異在於不用在人工加入 #ifndef 與 #endif, compiler已經幫我們做掉可能會發生重複 include的情形
- access rules
- public: @interface in .h
- private: @interface in .m, 但是方法後面要加 (), e.g. @interface privateMethod()
- @property
- build-in getter and setter
- private: -(double) value;
- public:
- -(double) value {return value;}
- -(void)setValue: (double) val {value = val;}
- 合成.h中: @property (nonatomic) double topSpeed; 而 .m中: @synthesize topSpeed =_ topSpeed;
- nonatomic為 not thread-safe的 keyword
- 上面其實就是實作了
- -(void) setTopSpeed: (double) speed
- {
- _topSpeed = speed;
- }
- -(double) topSpeed
- {
- return _topSpeed;
- }
- 可清楚看到不用 @synthesize topSpeed; 而是 @synthesize topSpeed = _topSpeed; 主要怕第二個 getter方法名與 member實際名稱相同帶來的困擾
- 另外也可以設定 pointer, 通常會搭配 strong的屬性, strong代表不會自動回收, 而 weak則是沒人用了就回收
- static
- return type前面 -為 non-static, +為 static
- @protocol
- non-class-specific methods
- @interface 對應 Java的 @class, 而 @protocol對應 Java的 @interface
- Ref: Protocol in Objective-C
- @category
- 擴充既存 class
- 一般只用於加 method
- 若擴充的 method檔名已存在, 則會以 category定義的為主
- Ref: Category in Objective-C
- 傳 message給 nil:
- 不像 c++會 crash, 這會....nothing happened, 在 debug要特別注意
- all objects in objective-C are in heap
2012年11月1日 星期四
[iOS] About Drawing and Printing in iOS
- Drawing Paths
- use native drawing
- Core Graphics and UIKit
- using drawRect: method to draw shapges, text, images, or gradients
- redraw- call setNeedsDisplay or setNeedsDisplayInRect: method
- use OpenGL ES
- key concepts
- in drawRect: method, UIKit creates a graphics context to render
- coordination
- origin: top-left of the view
- logical coordination space
- distance: in points, not pixels
[iOS] Windows and Views
- Windows
- 本身沒有任何內容 (content),他提供的是一個 app的 container,來存 views。
- 通常只有一個 window,除非有其他的螢幕畫面。
- 一個 app至少一個 window、一個 view
- instance of UIWindow
- Views
- 放置真實內容,例如 images, text, shapes, and so on。
- 其為 windows的一部分。
- instance of UIView
- manages a rectangular area in your application window
- responsible for drawing content, handling multi-touch events(by gesture recognizer or handing touch events directly), managing layout of subviews
[Notes] Graphics & Animation Starting Point
- Frameworks
- UIKit
- Objective-C API
- basic 2D drawing, image handling, ways to animate user interface objects
- Core Graphics
- C-based API
- vector graphics, bitmap images, PDF content
- Core Animation
- Objective-C API
- smooth motion and dynamic feedback to UI
- OpenGL ES
- OpenGL mobile version
- high-performance 2D and 3D drawing
- includes EAGL, an Objective-C API integrates OpenGL with Core Animation and UiKit
- Guides
- basic draw (UIKit)
- View Programming Guide for iOS
- iOS native coordination system, operations on views
- Drawing and Printing Guide for iOS
- using UIKit to draw
- CGContext Reference to find function call
- powerful 2D draw (Core Graphics- with Quartz 2D engine)
- Overview of Quartz 2D
- create pattern, path, gradient
- Quartz 2D Programming Guide
- animation
- chapter Animations in View Programming Guide for iOS
- sample: MoveMe
- games and advanced graphics by GPU
- OpenGL ES Overview
- sample: GLSprite
- Advanced studying (details)
- UIKit Framework Reference
- Core Graphics Framework Reference
- Core Animation Programming Guide
- OpenGL ES Programming Guide for iOS
- OpenGL ES Framework Reference
2012年9月14日 星期五
2012年9月12日 星期三
[Dropbox] Dropbox API
- 事前準備
- 必須申請 My apps的帳號
- 會給你一組 App name, key跟 secret
- 資料夾存取權限
- 某個與你 app同名的資料夾
- 完整 Dropbox資料夾
- 開發狀態
- 預設為 Development status
- 若要發佈為產品, 將其改為 Production status(在 My Apps頁面內), 則 Dropbox將會審核是否遵守規定
- SDK setup
- 由 Development kits下載 SDK
- python
- 下載後 sudo python setup.py install
- example資料夾有許多 dropbox API範例, e.g. cli_client.py提供 command line interface (CLI)
- 要能跑的話, 主要就是設定 app_folder存取權限、app key跟 app secret
- 可以嘗試玩玩 cli_client, 試試撰寫後提供的界面, e.g. help, login, logout, ...
- SDK中的 dropbox資料夾為主要 library, 最主要可能可能用到的是 session.py (認證) 與 client.py (呼叫 API call)兩檔案, 若要自己實作 API call則更改 rest.py
- iOS
- run samples
- 下載 SDK後即擁有範例 project: DBRoulette, 可開啓 xcodeproj專案檔, 不過要更改
- examples/DBRouletteAppDelegate.m中 application:didFinishLaunchingWithOptions方法中的 appKey, appSecret跟 root值, 注意, Root請參考其程式註解 kDBRootAppFolder或 kDBRootDropbox(整個 dropbox資料夾權限)
- DBRoulette-Info.plist的 APP_KEY這字串改為你的 app key
- 就可以看到完整範例程式啦~
- 加入自己的 project
- 將整個 DropboxSDK.framework資料夾 copy到自己的 project, 另外, 要加入 Security.framework與 QuartzCore.framework(在 target, Build Phases中的 Link Binary with Libraries用 + 來加入)
- 加入 Authentication
Ref: Dropbox for developers
2012年9月5日 星期三
訂閱:
文章 (Atom)