2012年7月12日 星期四

NSDictionary

係宜家用得算多既係NSArray NSDictionary

頭先睇NSDicitionary 有一個幾特別既message enumerateKeysAndObjectsUsingBlock:

用一個block 去loop though 成個dict 一直都想用多啲block 下次有機會用下

近況

做左一個星期intern  2010-mid MBP 就死左 死左logic board 整又要五千蚊 寧願買部新都無咁嬲 

新機六月尾到左 同舊機無咩大分別 一樣咁既速度(感覺上) 一樣咁重

宜家幫一間投資銀行整app 成個六月就寫 今個星期係咁bug fix 

有好多野唔係想像中咁容易 客既data 永遠有機會同document 講好左既唔同(咁要document 為乜?) 

今日老闆早啲係公司 而我想今日ko 一直想refactor 既function 宜家洗個頭就落公司

2012年6月4日 星期一

MBP dead

差唔多兩年就掛了… :(

2012年5月31日 星期四

VBoxManage modifyhd Rails.vdi --resize 16384

VBoxManage modifyhd Rails.vdi --resize 16384

呢句command 用黎resize current virtual HD 仲要extend 個partition 同埋format 架 

2012年5月22日 星期二

iOSskills view hierarchy

//Recurive Message to find view hierarchy
-(void)findSuperView:(id)theView
{
    if ([theView superview] != nil) {
        NSLog(@"%@" , [[theView superview] class]);
        [self findSuperView:[theView superview]];
    }
   
}


UINavigatorController

終於到左NatvigationController

NatvigationController 會儲住一個stack 而呢個stack 既elements 係一堆viewControllers



















Push 推elements 入stack
Pop 拎elements 出stack
Top 最尾既element 都係第一個pop出黎
Base 最頭一個element


//push to next controller

    if (childController == nil) {
        childController = [[BIDDisclosureDetailController alloc]
                           initWithNibName:@"BIDDisclosureDetail" bundle:nil];
    }

//set childController properties
    childController.someMessage = detailMessage;
    childController.title = selectedMovie;
    [self.navigationController pushViewController:childController
                                         animated:YES];

[self.navigationController pushViewController:nextController animated:YES];

//pop (go back) to previous controller
[self.navigationController popViewControllerAnimated:YES];

//The view controllers currently on the navigation stack.
NSArray *allControllers = self.navigationController.viewControllers;

//retrieve last controller pushed into stack
UITableViewController *parent = [allControllers lastObject];

//reload data of parent tableview
[parent.tableView reloadData];

2012年5月21日 星期一

iOSskills selector

iOS 有個compiler driective 叫做@selector 用黎send message 比target

From Documentation
In Objective-C, selector has two meanings. It can be used to refer simply to the name of a method when it’s used in a source-code message to an object.

例如有個UIButton

UIBarButtonItem *moveButton = [[UIBarButtonItem alloc] initWithTitle:@"Move" style:UIBarButtonItemStyleBordered target:self action:@selector(toogleMove)];

target:self > 即係自己呢個class

toogleMove 係message name

- (IBAction)toogleMove{

...

}

如果想call既messge 有parameter 咁會變成 action:@selector(toogleMove:)

無parameter 就會唔好手多加 : 唔係compiler 搵唔到你想call message

P.S. 如果個message 有parameters

[friend performSelector:@selector(gossipAbout:) withObject:aNeighbor];



2012年5月20日 星期日

TableViewController

TableViewController


















呢個controller 好常用 可以做黎例曬data 更可以select一個之後push 下一個controller

有兩個protocoal 要conform
UITableViewDelegate
-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
設定每一row 既indentation . 如果每個row 多一個indentation return [indexPath row];


-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
設定每一個row 可唔可以被selected 例如第一個row 唔可以select

NSUInteger row = [indexPath row]
if(row== 0)
return nil;
return row;

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
設定每一個row既高度 return 70;



UITableViewDataSource
 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
一個section 入面有幾個row

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
每一個TableViewCell既setup
 

iOSSkills NSBundle NSURL

有陣時App 會用到一啲existing既file

例如有個static既file 叫做 fileName.ext


NSBundle *bundle = [NSBundle mainBundle]; //係app folder入面搵

NSURL  *someFileURL = [bundle URLForResource:@"fileName" withExtension:@"ext"];

如果用NSString:

NSString *path = [[NSBundle mainBundle] pathForResource:@"fileName" ofType:@"ext"];

如果係plist

NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:someFileURL];

如果係wav

 SystemSoundID soundID;
    AudioServicesCreateSystemSoundID(
                                     (__bridge CFURLRef)someFileURL, &soundID);
    AudioServicesPlaySystemSound (soundID);

2012年5月19日 星期六

iOS skills setValue:forKey:

除左之前係針對UI elements 去學
仲有啲特別野係可以其他地方都用到

[self setValue:someValues forKey:keyNameOrVariable];
呢個message係一啲regular 既variable name好有用
例如你有五個NSArray

NSArray arr1 =...
NSArray arr2 =...
NSArray arr3 =...
NSArray arr4 =...
NSArray arr5 =... 

而每個NSArray 都要init 同比啲elements

for (int i = 1 ; i <=5 ; i++)
{
initialize..
initialize needed objects..
NSArray *tempArray = [[NSArray alloc] initWithObjects:obj1, obj2, obj3 , .. nil];f
NSString *arrayName = [[NSSting alloc] initWithFormat:@"arr%d" , i];

[self setValue:tempArray forKey:arrayName];
}
咁就set 曬全部array

P.S. From Beginning iOS 5 Development Apress Chapter 10



MultiView switching , TabBarController and PickerView

自從琴日interview見到自己既不足,今日“的”起心肝去認真學

手頭上都有五六本iOS 5 既dev ebook雖然又黎一年一度既WWDC

不過宜家黎講都叫最新 睇住黎學啦

我今日跟既本係Apress既 Beginning iOS 4 Development

http://www.apress.com/9781430236054

其實其他書都有講UINavigationController 但係呢本勝在 全面啲 多啲examaple

Chapter 9係UINavigationController 但係一開始作者又refer 到之前既example 咁無計啦 睇返前面

Chapter 7係點handle multiple views 由Window template 無XIB 開始
係appDelegate 連rootController
再係rootController加個ToolBar view同埋一個switching 既subview
唔難 但係清左concept

Chapter 8 TabBarController 同pickerView


呢個chapter 用一個tabBarController 去比user switch 五個唔同既view 每個view 都獨立既pickerView 由好簡單選擇日期(datePicker)
去到有個一個component 兩個獨立component
以至一個component depends on 一個component 最後一個簡單既老虎機


pickerView有datasource 同delegate 兩個protocol 要conform


data source:

-(NSInteger) numberOfComponentsInPickerView:(UIPickerView *)pickerView
個picker有幾多component 多數return 一個int

-(NSInteger) pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
一個component有幾多個row (options) return [self.array count];


delegate:

-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
呢個message 係return 返相對應既row 字串 return [self.array objectAtIndex:row];

而component 可以用if 去拎 if(component == 0 ) return [self.someArray objectAtIndex:row];


-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
當user 係一個component 選擇左之後有咩要做 例如populate 另一個component

-(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
呢個message 做少少interface 既改動 自訂每一個component既width (in pixel) return 90;









2012年5月18日 星期五

表現麻麻

今日表現其實幾差 答非所問
人地問左咩chenellges
點講都唔對題 係度遊花園 人地講左例子先知要講乜
人地問有咩常用既viewcontroller 問到一個UITableViewController 無 意會唔到UINavigationViewController 都係
orientation 又唔識答 只係話用default setting 點知iPad orientation 好重要 要識點處理
又問返cocos2d scene同layer既分別 我答得唔夠肯定
好彩iOS 5 有咩development advantage 仲答到...
縱合黎講 我覺得自己表現唔太好 又唔熟iOS5 ...黎緊啲日子要惡補一下

P.S. 頭先interview 仲唔知點解仲有個壞習慣 除左隻手錶係人地面前玩… 到底今日做緊乜?


2012年5月11日 星期五

回音

自從報左green tomato之後一直等消息 由三月尾等到四月 到宜家五月中 咁耐都仲未有真正既interview 到底佢地想點??

為免夜長夢多 報左兩個internship 。

舊公司老闆問我想唔想返去幫手 諗下仲可以 一諗起返到去執手尾(包括人地同自己) 學唔到太多野 而且又唔係自己想學  呢個係最後先會考慮

希望呢個暑假入間寫app既公司 睇下人地真正點去諗點去寫點推個app出市場 最好可以year 3 做埋part time 一黎錢 二黎儲經驗 始終覺得自己唔明成個app development 既流程 點設計 自己睇書又好似好散咁

仲有兩科考試 考埋真係搭尾班車搵intern

2012年5月10日 星期四

唔小心

今日返去cityu 溫 陪danny同昌哥 去水手食飯 點知janet打黎 同我講CV好多問題 好有心同我講之餘 過左deadline都比時間我改 有時我覺得我既運氣可能唔令到我中到抽獎六合彩 但係係呢啲影響人生影響前途既野上面 總係有人會出黎提我幫我 好感恩佢地對我既關愛同付出
Janet 提我一句 真實工作時好多野好急 但係一定要交之前自己把好個關 唔好比啲甩漏影響人地既印象
其實份之前都拎過比CAIO既人改過 但係可能果時改唔曬 自己又心急 求其交左就算
好多都係自己唔小心 又唔跟好啲 好彩好多時都有人提 唔係pk都似

2012年5月6日 星期日

unrar

如果你有堆rar file 你會點做?
對於我呢啲懶人唔會一個個unrar 費時失事
諗起ubuntu 有7z 既command line version
立即用黎試下


for f in *.rar; #先列出全部rar file
do mkdir "./stuff/$f" ;  #做一個同rar file同名既directory (注意directory name 唔可以同file 一樣名 所以用stuff 多一層隔住)
7z -o./stuff/$f e "$f"; #-o 係Set output directory -o同path無空格 e extract
done; #close loop



解曬出黎 每個rar有一個folder 儲住啲content 但係好衰唔衰佢有啲file corrupt左(unsupported method) 


刪曬啲output再黎
man unrar
但係unrar又無得set output directory .............


搞完一陣
係windows 裝7z
right click 全部rar











Extract to"*\" Done.

2012年5月3日 星期四

打機+溫書 =ineffective

本身諗住用電腦copy n paste lecture notes 呢整份notes 拎黎溫書 滿以為自可以控制慾望 反而被慾望控制 唉

2012年4月24日 星期二

iOS5.1 iPhone simulator

之前既iOS simulator 都無location service 宜家有左可以玩到location based app

頭先跟本書做 無係viewDidLoad 果度init CLLocationManager 唔怪得無經緯度啦

2012年4月23日 星期一

三國志七 三

今次都係用張遼 但一開始劇本係跟呂布 先打馬騰 拎左西北角落 之後向中原發展 漢中張魯同劉璋打 而中原由袁氏同曹操同埋陶謙爭 之後曹操比人逼落江南 仲劉表係荊洲 張魯同張照(陶謙去左) 不斷比錢呂布 我帶住兵打入成都同雲南 同時曹操都解決各個大小諸侯 係江南同中原站穩住腳 同呂布一決雌
雄 曹操軍入面猛將如雲 呂布軍一個個城被佔 最後曹操一統天下

2012年4月19日 星期四

隨心

雖然今個sem都好多project 但係感覺上無上個sem咁負面

今個sem 多左leadership 既role

例如帶成組向著一個方向傾 唔好扯開左個話題

又逼下其他人 問下佢地幾時得閒做野呀 rehearsal 咁

辛苦 不過覺得真心出力做野好似都好enjoy

宜家都唔多顧成績 向著自己想既方向盡力做好己經心滿意足 成績都唔重要啦!

2012年4月15日 星期日

三國志七 二

今次用張遼 原來張遼都好勁 平均能力值七十幾 跟住曹操 打到孫策得返半個荊洲

死亡之週

Week 13! 死亡之週 5 個presentations 1個report 點算好!!

2012年4月9日 星期一

三國志七

今日玩左成日三國志七 孫吳一直都係咁強大 連曹操都擋唔住

好耐都無寫過blog了

都唔記得左幾時之前寫個Blog 唔follow up之前既post 啦

報告下宜家既近況

宜家year 2 sem B 尾 week 12

仲有好多科未present 同交report 好彩今次搭住啲做到野既人 起碼做既野無咁辛苦

五月頭開始有四個考試 平均黎講都有兩三日溫 又無同一日考兩科 感覺上都還可以

只不過比較擔心黎緊week 13 會應付唔到日日都要做既present 同交report

另外前果排都有報左幾間internship 包括號green tomato / guru online

而且green tomato 係最想做 最想係果度真正學下iPhone app 係點寫

Guru online 只不過係以防不測

兩邊都仲未有消息 可能未開始interview period 掛

趁住未有消息 自己係部小米放返兩本iOS 5 dev eBook 有時間睇下

加深自己對Objective-C 既認識同功力

岩岩自己求其寫左個console 既app 試下啲寫一個class 同call init 有幾個重點要留意:


  1. init 一定係 instance method 即係 minus 開頭 
  2. NSString 係inmutable  stringAppendbyString 係會出一個新既instance 
  3. 如果一定要mutable 既NSString  一定要用NSMutableString



2012年3月6日 星期二