Posts

Showing posts from 2016

NSOperation和NSOperationQueue

NSOperation和NSOperationQueue NSOperation和NSOperationQueue NSOperation 是 GCD 的封裝,是完全的物件導向類別,所以使用起來更簡單。 大家可以看到 NSOperation 和 NSOperationQueue 分别對照 GCD 的 Task 和 Queue 。 將要執行的任務封装到一個 NSOperation 物件中。 將此task添加到 NSOperationQueue 物件中。 然後系統就會自動執行任務。至於是同步還是異步、串行還是並行繼續往下看: 加入Task NSOperation 只是一個抽象類別。 抽象類別是不能產生實體的類別,所以不能封裝task。 但有 2 個子類別是可以用封裝任務。 分别是:NSInvocationOperation 和 NSBlockOperation 。 建立一個 Operation 後,需要使用 start 方法啟用task,他會在當前的序列進行同步執行。而且也可以取消任務,只需要使用 cancel 方法即可。 NSInvocationOperation : 需要傳入一個方法。 OBJECTIVE-C //1.建立NSInvocationOperation物件 NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget: self selector :@ selector (run) object: nil ]; //2.開始執行 [operation start]; //SWIFT 在 Swift ,蘋果認為 NSInvocationOperation 這種不是安全的類別。 As of Xcode 6.1, NSInvocation is disabled in Swift, therefore, NSInvocationOperation is disabled too. See this thread in Developer Forum Because it’s not type-safe or ARC-safe. Even

IOS GCD多執行緒

IOS GCD多執行緒 GCD 簡稱 Grand Central Dispatch ,利用在CPU(雙核,多核心的平行運算), 自動管理Thread的Liftcycle ,(創造執行緒,調度Task,消除執行緒),不用自己管理Thread。 GCD Objectivc-C 使用Block Swift 使用Closure Task & Queue Task: Operation ,一個程式區段,在GCD裡面就是Block或者Closure 有兩種操作模式: sync & async 差別在於是否創造 “新的Thread” 同步執行 同步操作會阻礙當前執行緒執行並等待,等當前執行緒完成才繼續執行 異步執行 異步操作,當前執行緒會繼續往下執行,不會阻礙執行緒 Queue Serial Queues(串行序列) 會進行FIFO(First in First out) Concurrent Queues(並行序列) 也是FIFO取出,但取出後會開啟多條執行緒直接取出又放到另外一個執行緒,由於取出動作很快,看起來所有任務同時執行,但是自根據系統資源控制並行數量,所以如果任務很多,不會同時讓任務一起執行。 Item sync async Serial Queues 執行緒,一個一個執行 其他執行緒,一個一個執行 Concurrent Queues 執行緒,一個一個執行 很多執行緒,同時執行 創造Queue Main Queue Create Queue Global Queue Main Queue mainqueue為自定義變數 /*OBJECTIVE-C*/ dispatch_queue_t mainqueue = dispatch_get_main_queue(); /*SWIFT*/ let mainqueue = dispatch_get_main_queue() Create Your Own Queue 自己可以創建串

HTML複習

HTML複習 Html hyper text markup language 標準定義單位 http://www.w3.org 基本網頁運行環境介紹 http://feevocode.blogspot.com/2016/04/ap102-2016413.html html4 與html5 標準範本下載 https://github.com/DarisCode/HTML/tree/master/html Tag A pair Tag <h1>This is h1<h1/> single Tag - <br> <br/> free-formate : Html不會受大小寫影響 Attribute 屬性 < a href= "" > //href 是 a 標籤的屬性 "" 內的值是屬性 html 4.01版的重點 text & pr 3 -

IOS 考題

IOS 考題 1. 宣告一個方法 帶入兩個名字 例如:JASON&OLIVIA ,方法不回傳值, 並且印出[JASON LOVE OLIVIA]。 -( void )jasonSayHelloToOlivia:( NSString *)name1:( NSString *)name2 { NSString * name1 = JASON; NSString * name2 = OLIVIA; NSLog (@ "%@ LOVE %@ " , name1 , name2 ); } 2. 宣告一個方法 帶入兩個整數,這個方法會回傳[比較大]的整數。 如果兩個整數相等,回傳任一個整數 -( int )comparteWithBigOne:( int )numberOne AndNumberTwo:( int )numberTwo { if (numberOne>numberTwo) { return numberOne; } else { return numberTwo; } 3. 宣告一個陣列,放入分數,分別是1,2,3,4,5,6。 另外宣告一個方法收到這個陣列,並求出平均 let scores = [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 ] var avg= 0.0 var sum= 0.0 let G = scores.count for i in 0. .<G { sum = sum + scores[i] print (scores[i]) } let b = Double(G) avg = sum / b print ( "sum=" + "\(sum)" ) print ( "average=" + "\(avg)" ) 4. 有一個菜單如下 黑咖啡 25 鬆餅 40 冰淇淋 50 拿鐵 60 每日點心 60 請宣告一個方法,帶入客人所點的品項名稱,並將總金額計算出來並回傳。 5. 請另外宣告一個方法,會帶入客人所點的品項與

AP102 2016/7/25 下午silvia RWD

專案管理 https://trello.com git / svn https://backlogtool.com/git-guide/tw/ 設計流程 0.使用CardSorting 1.SiteMap 2.FlowChart 3.Wireframe(不要放顏色,放圖檔) 可轉換成線稿 https://www.wirify.com/ 或者使用手繪 Paper prototyping 4.Mockup https://gomockingbird.com/ 5.Prototype(for 內部測試) http://www.teehanlax.com/tools/iphone/ 測試是否是RWD responsive Design bookmark 不要換頁 40 120 888 84 pt 繪圖範圍 標準 72dpi 1px = 1pt Retina 2px = 1pt RWD常用 em單位 16px = 1em 1/1.62 Media Queries Fluid Grid http://960.gs header : width:100% padding margin border if positrion:absolute 不要再寫padding

IOS Topic

Error Handling https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/ErrorHandling.html  iphone size http://www.apple.com/iphone/compare/

Html 視窗與位置

Html 視窗與位置 依此方法可以連到特定區域 < h1 id = "t1target" > < a href = "www.google.com#t1target" > 開新視窗 “`

Html-連線上網

Html-連線上網 受歡迎的主機商推薦 http://www.wickedlysmart.com/hosting-providers/ %ftp www .google .com Connected to www .google .com Name: XXX password: XXX dir cd google put index .html dir mkdir images cd images bye put <filename> //傳送指定檔案至伺服器 get <filename> //從伺服器取得指定檔案,傳回電腦中 FTP MAC OSX Fetch $ Transmit $ Cyberduck (free) Windows Smart FTP $ WS_FTP (basic version is free Advanced version $) Cyberduck (free) URL Uniform Resource Locators (統一資源定位碼) 網址名稱 www.google.com google.com是網域名稱 www.google.com是網站名稱 http://www.google.com/index.html https:協定(protocol) www.gooogle.com網站名稱 index.html絕對路徑 微軟的預設檔案為default.htm 少一個l較為特殊 Web常用Unicode代碼 http://www.w3schools.com/charsets/ref_html_symbols.asp Unicode代碼 http://www.unicode.org/charts/

IOS多執行緒

IOS多執行緒 关于iOS多线程,你看我就够了 http://www.jianshu.com/p/0b0d9b1f1f19 NSURLSession 教程 http://www.jianshu.com/p/045cdfdaaf6e NSURLSession with NSBlockOperation and queues http://stackoverflow.com/questions/21198404/nsurlsession-with-nsblockoperation-and-queues iOS 並行程式設計: 初探 NSOperation 和 Dispatch Queues http://www.appcoda.com.tw/ios-concurrency/ background-transfer-service-ios7 http://www.appcoda.com/background-transfer-service-ios7/ Parsing JSON in Swift http://chris.eidhof.nl/post/json-parsing-in-swift/ How do I use NSOperationQueue with NSURLSession? http://stackoverflow.com/questions/21918722/how-do-i-use-nsoperationqueue-with-nsurlsession Operation Queues Cocoa operations are an object-oriented way to encapsulate work that you want to perform asynchronously. Operations are designed to be used either in conjunction with an operation queue or by themselves. Because they are Objective-C based, operations are most commonly used in Cocoa-based applications in OS

closure

closure Swift functions are closures. 意思就是closure可以在function的範圍內抓外部變數來引用 來看一下這段程式碼 class Dog { var whatThisDogSays = "woof" func bark() { print ( self .whatThisDogSays) } } 這段程式碼裡面函式指向一個變數whatThisDogSays 那變數在函式外部,因為它宣告在函式的外部,但內部的還是可以看到他並使用,因此函式bark 可以傳遞value,但whatThisDogSays 的reference 是怎麼傳遞的? func doThis(f : Void -> Void ) { f() } let d = Dog() d . whatThisDogSays = "arf" let f = d . bark doThis(f) // arf 在上面這段程式碼裡面,我們並沒有直接呼叫bark 我們創造一個Dog的實體物件d,然後傳遞bark的方法值到doThis 現在whatThisDogSays 是一個實體屬性屬於Dog類別 雖然在doThis這個方法裡面沒有whatThisDogSays 的確,在方法內doThis沒有Dog 的物件,但f()仍然可以運作 這個方法d.bark,即使他被到處傳遞,卻仍然可以看到被宣告在外的變數whatThisDogSays ,即使whatThisDogSays 這個被呼叫的變數不屬於Dog類別的物件,也不屬於任何物件的方法。 bark方法

Title3

Image
Title3 版本控制工具(Version Control System, VCS),傳統上先鎖定,然後再取出修改。 再完成修改與回傳前,其他人不能修改。 後來採用分散式作法,隨時取得然後合併(merge),Git就是這種分散式的系統。 市面上目前常用的VCS工具主要有 1.SVN 2.GiT 從2014年以後GIT正式超越SVN git的開發者是Linux的作者 Linus Torvalds 一開始 Linus Torvalds 使用BitKeeper一開始免費使用,後來開始營利。 但卻找不到免費可使用得好的版本控制工具。 當時Git的程式碼用來管理有將近七百萬行的Linux專案 Git下載 https://git-scm.com/ 在安裝畫面記得放上

IOS-charts 方法

IOS-charts 方法 var ViewForLine : [LineChartView] = [] var ViewForBar : [BarChartView] = [] //label: "Line Chart" 圖表示意 let lineChartDataSet = LineChartDataSet(yVals: dataEntries, label: "Line Chart" ) let lineChartData = LineChartData(xVals: dataPoints, dataSet: lineChartDataSet) //資料來源 ViewForLine .first ! .data = lineChartData //圖表背景顏色 ViewForLine .first ! .backgroundColor = UIColor(red: 85 / 255 , green: 85 / 255 , blue: 85 / 255 , alpha: 1 ) // X 軸圖標位置 ViewForLine .first ! .xAxis .labelPosition = .Bottom //右軸是否開啟 ViewForLine .first ? .rightAxis .enabled = false //左軸圖標位置 ViewForLine .first ? .leftAxis .labelTextColor = UIColor .whiteColor () // X 軸的 X 刻度標記顏色 ViewForLine .first ? .xAxis .labelTextColor = UIColor .whiteColor () //圖表描述文字色彩 ViewForLine .first ? .descriptionTextColor

Title24

Title24 // // BarLineChartViewBase.swift // Charts // // Created by Daniel Cohen Gindi on 4/3/15. // // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda // A port of MPAndroidChart for iOS // Licensed under Apache License 2.0 // // https://github.com/danielgindi/Charts // import Foundation import CoreGraphics #if ! os(OSX) import UIKit #endif /// Base-class of LineChart, BarChart, ScatterChart and CandleStickChart. public class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartDataProvider, NSUIGestureRecognizerDelegate { 最大可顯示數值計算 /// the maximum number of entries to which values will be drawn /// (entry numbers greater than this value will cause value-labels to disappear) ## 最大可顯示數值計算 internal var _maxVisibleValueCount = 100 自動顯示比例 /// flag that indicates if auto scaling on the y axis is enabled private var _autoScaleMinMaxEnabled = false private var _autoScale

Title23

Title23 AppDelegate.m - ( BOOL )application:( UIApplication *)application didFinishLaunchingWithOptions:( NSDictionary *)launchOptions { // Override point for customization after application launch. return YES ; } AppDelegate.h/m define a class that manages the application overall. AppDelegate.h/m 定義了一個類別可以管理整個應用程式 The app will create one instance of that class and send that object messages that let the delegate influence the app’s behavior at well-defined times. For example, 這個應用程式會創造一個實體給類別去傳送物件訊息 讓代理影響明確定義到所有的應用程式行為 例如: -application:didFinishLaunchingWithOptions: is sent when the app has finished launching and is ready to do something interesting. 當應用程序已經完成啟動,並準備做一些有趣的事情被發送。 Take a look at the UIApplicationDelegate reference page for a list of messages that the app delegate can implement to modify the behavior of the application. 看看在UIApplicationDelegate參考頁的應用程序委託可以實現修改應用程序的行為信息的列表。 相當於Asp.Net 中的 Global.ascx ,做全域變數的控制。 AppDele

IOS Target

IOS Target Target算是單一執行檔 通常商業版 一個專案會有多個Target 可以同時服務三種版本 例如:免費版,付費版,旗艦版

如何在Mac 中顯示隱藏檔案

如何在Mac 中顯示隱藏檔案 顯示隱藏檔案: defaults write com .apple .finder AppleShowAllFiles TRUE ;\killall Finder 不顯示隱藏檔案: defaults write com .apple .finder AppleShowAllFiles FALSE ;\killall Finder

Title22

Title22 windows 1. install USB driver 華碩是最好安裝的 2. 開發人員選項 對著版本號碼 點七下 跳出關於開發人員選項 要讓Allow USB debugging出現勾選確認 Mac

Title21

Title21 top buttom 與文字的順序有關 左到右的文字是左邊是Leading右邊是trailing Leading trailing Size Class Compact Regular w/h table W:compact W:ragular H:compact iphone lay down iPhone6 Plus H:ragular iphone ipad 1. 2.ARC的機制是什麼? NSString * var1 =@”This is ARC “ “This is ARC” 被宣告了記憶體 宣告時,指標var1這個counting 被+1 此時不能release NSString * today = var1 var1此時已被呼叫兩次 reference counting已經+2 [var1 retain] [var1 retain] 後面要有對稱的release @property (weak,nonatomic) weak時 reference counting不會+1 但strong會 weak>>會設成nil assign>>不會設成nil alloc copy new 都會讓reference counting+1 1.Serial(一次一個) Serial Queue (private dispatch queues) 依照放入的順序一次執行一個 block,通常用於存取指定的資源。 我們可以依照需求建立許多不同的 Serial Queue 2.Concurrent(一次可執行多個) Concurrent Queue (global dispatch queue) 依照放入的順序和系統目前 資源的狀態執行多個block。 3.Main dispatch queue(Serial) 在應用程式的main thread中執行被指定的動作。 Closure 算是一種物件,也是ARC Closure = block

D-U-N-S 鄧白氏檔案查詢 IOS企業帳號申請

Image

MSSQL 常用語法

MSSQL 常用語法 查詢 SELECT [id] ,[major_trader_id] ,[net_amount] ,[tradedate] FROM [quotefutures].[dbo].[futures_major_trader] where [tradedate] = '2016-06-28 00:00:00.000' 刪除 DELETE FROM [quotefutures].[dbo].[futures_major_trader] where [tradedate] = '2016-06-28 00:00:00.000' select * from (select top 30 * from quotestock.dbo.TSE100Price ORDER BY tradedate DESC) k order by k.tradedate;

AP102 2016/6/27 JAVA 第一堂

AP102 2016/6/27 JAVA 第一堂 public class MainClass { public static void main (String[] argv) { byte b = 1 ; short s = 2 ; int i = 3 ; long l = 4 ; float f = 1.1 f; double d = 1.2 ; boolean bool = true ; char c = 'a' ; String text = "hello world" ; System.out.println( "b = " + b + "\ns = " + s); } } 強制轉型 class Casting{ public static void main (String[] args){ int i = 1 ; double d = 11.1 ; double sum1 = i + d; int sum2 = ( int )(i + d); System.out.println(sum1); System.out.println(sum2); } } 數字與字串串接 class ConcatenateOP{ public static void main (String[] args){ String str1 = "123" ; String str2 = str1 + 10 ; int i = 123 ; double d = 3.12 ; System. out .println(str2); Sys

changing property contentsGravity in transform-only layer, will have no effect

changing property contentsGravity in transform-only layer, will have no effect changing property contentsGravity in transform-only layer, will have no effect Ans: stackView需要改成Scale to Fit 即可

Title20

Title20 1.砍掉原本的ViewController(mainstory board) 也要移除左邊的ViewController.swift然後move to Trash 2.建立一個UITableViewController 3.然後Is Initial View Controller 4.建立一個UITableViewController的類別 5.點擊mainstoryboard的Custom Class來建立關聯 6.建議Cell 的 identifier (要在attributes inspector建立 7.更改Row Height 8.加入imageview, Label 9.進行Stack 10.設定成Top left right bottom (2,6,0,2) 11.創造一個類別NameBookTableViewCell 在類別內建立IBAction @IBOutlet var ReadmeButton: UIButton! @IBOutlet var TitleLabel: UILabel! @IBOutlet var thumbImageView: UIImageView! 12.MainStoryBoard繼承這個類別 13.由mainstoryboard左邊的Cell拉IBAction 連結

Swift TableView

Swift TableView 1.拉一個Table View 2.Table View右方的 Prototype Cells 從0改成1 3.點選cell 將identifier處輸入Cell 宣告類別 UITableViewDelegate UITableViewDataSource 是protocol protocol算是一種需求 需要UITableView顯示出來需要開出需求清單 例如: 表格裡面你要繪製出多少列,裡面要提供多少資料? 而可以藉由代理物件delegate object delegation pattern class ViewController: UIViewController , UITableViewDelegate , UITableViewDataSource 補上這段程式碼 class ViewController: UIViewController , UITableViewDelegate , UITableViewDataSource { override func viewDidLoad() { super .viewDidLoad () // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super .didReceiveMemoryWarning () // Dispose of any resources that can be recreated. } func tableView(tableView: UITableView , numberOfRowsInSection section: Int) -> Int { //回傳總列數 //總共看陣列有幾個物件就回傳幾列 return studentNames .count } func tableView(tableV

AP102 2016/6/21

AP102 2016/6/21 Sketch 3 取消Borders EDIT-> Set Style As Default R矩形 按shift就是正方形 O圓形 按shift就是正圓 L線 U有角矩形 星形 可以使用多 圖層 Shift連選 點選右鍵Group selection 再按一次就是解除Ungroup Union 連集合 直接把資料夾拉出去至桌面 就可以產生圖片 遮罩 Mask ArtBoard 視同一個輸出範圍 程式的大小是point 點程式 實際像素是pixel 像素 ipad full screen Pixel iphone3Gs: 320* 480 iphone4 : 640 * 960 iphone5/5s: 640 * 1136 iphone6/6s: 750 * 1334 iphone6+/6s+: 1242 * 2208 Point: iphone5: 320 * 568

Title17

Title17 SKProductsRequest * productsReq = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObjects:@ "tw.pitch.unlimited" ,@ "tw.pitch.30coin" , nil ]]; //用server取得可用貨號可更為彈性 //指定產品要求的 delegate 對象 productsReq .delegate = self ; 要在這一行加入 <SKProductsRequestDelegate> @interface StoreTableViewController () <SKProductsRequestDelegate> 然後再新增一行 - (void) productsRequest: ( SKProductsRequest *) request didReceiveResponse: ( SKProductsResponse *) response{ }

Title15

Title15 1. Git Project 來自於smalltalk 從NsXTStep -> OpenStep ->CocoaTouch 記憶體自動管理 ARC automatic reference counting 可防止記憶體滲漏(memory leak) 釘選你的Xcode 使用GitHub –> fork一個函式庫 Xcode基本框架 版本管理工具Xcode也可以使用 包含Subversion Assistant editor 2.Getter與Setter MVC設計模式降低了程式碼 2.5.語法 3.表格與視圖 4.Segue 5.照相機 6.CoreData 7.NSfetchRequest 8.UIImagePicker

Markdown懶人包

Xcode 常用工具

Alcatraz Jazzy Carth PaintCode2  把向量圖轉程式 PaintCode-plug-in程式碼 fastlane上架截圖 Apple Account 雙重認證要記得取消 IOS-UI test 內建記錄動作

網址註冊

網址註冊 GOOGLE https://www.google.com/webmasters/tools/submit-url?hl=zh_TW YAHOO http://tw.info.search.yahoo.com/free/request BING http://www.bing.com/webmaster/SubmitSitePage.aspx 天空 http://reg.yam.com/Register/register.asp

FaceBook 外掛

粉絲專頁外掛程式 https://developers.facebook.com/docs/plugins/page-plugin

Head First Javascript 2

深入淺出javascipt 前情提要 快速瀏覽 1.變數命名方式 2.保留字 3.註解與被拒絕的變數命名 4.迴圈 5.判斷句 6.文件物件模型 alert document.write console.og document.write('來一次') 上面這一行會把字寫進瀏覽器 7. 使用console.log 8. 兩種方式使用javascript Q&A 1.如果點擊prompt中的cancel會傳回什麼值? A.將會傳回null(沒有值) 2.如果prompt函式總是會傳回一個字串。那麼字串(像是"0"或是"6"') 如何能夠與數字(像是0或者是6)做比較? A.這種情況下,JS試著將字串轉換成數值 3.如果輸入的不是數字而是six或者quit這類的字 A.那將無法進行熟比較 將會傳回false,會導致miss結果,但之後將會在程式中加入檢查數字輸入的語法 4.使用OR運算符,當其中有一個測試項目為true時可以取得ture 那兩個同時為true 可以 5.有and運算嗎? 有 6.無窮迴圈是什麼? 因為沒有在迴圈語法內終止而導致的循環程式 比較運算符號 < > ==(等於) ===(完全等於) <= >= != ||    (OR) &&  (AND) !