일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- setting
- 신도림
- 포켓몬 GO
- 샘플
- simulator
- 페이백
- 아이폰7
- swift3
- push
- Example
- IOS
- swift
- 포켓볼
- GCD
- loop
- 얻는법
- UIView
- afterdelay
- 공략
- 앱스토어
- Bitcode
- LG유플러스
- 보라카이
- 신도림 테크노마트
- UITableView
- Check
- Xcode
- error
- 해몽
- 스마트폰
- Today
- Total
목록swift (28)
도래울
extension NSURL { func getKeyVals() -> Dictionary? { var results = [String:String]() let keyValues = self.query?.componentsSeparatedByString("&") if keyValues?.count > 0 { for pair in keyValues! { let kv = pair.componentsSeparatedByString("=") if kv.count > 1 { results.updateValue(kv[1], forKey: kv[0]) } } } return results } }
var timer = NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: Selector("someSelector"), userInfo: nil, repeats: false) func someSelector() { // Something after a delay }
BRYXBanner is a great new library by Harlan Haskins for displaying "dropdown" notifications banners. It has a very straightforward API, while remaining extremely flexible. Let's take a look at some different ways to use it.Momentarily show a banner. By default banners are dismissed on tap, swipe, or after the duration has elapsed.let banner = Banner( title: "New Mission Alert", subtitle: "New mi..
var indexPath1 = NSIndexPath(forRow: 1, inSection: 0) var indexPath2 = NSIndexPath(forRow: 1, inSection: 0) var indexPath3 = NSIndexPath(forRow: 2, inSection: 0) var indexPath4 = indexPath1 println(indexPath1 == indexPath2) // prints "true" println(indexPath1 == indexPath3) // prints "false" println(indexPath1 == indexPath4) // prints "true" println(indexPath1 === indexPath2) // prints "true" pr..
var string = "hello Swift" if string.rangeOfString("Swift") != nil{ println("exists") } // alternative: not case sensitive if string.lowercaseString.rangeOfString("swift") != nil { println("exists") }
for view in self.view.subviews as! [UIView] { if let textField = view as? UITextField { if textField.text == "" { // show error return } } }See "Downcasting" in the Swift book.Update for Swift 2: As of Swift 2/Xcode 7 this can be simplified.Due to the Objective-C "lightweight generics", self.view.subviews is already declared as [UIView] in Swift, therefore the cast is not necessary anymore.Enume..
By far the best way to do this in Swift for iOS is:view.subviews.forEach({ $0.removeFromSuperview() }) // this gets things done view.subviews.map({ $0.removeFromSuperview() }) // this returns modified array^^ These features are fun!let funTimes = ["Awesome","Crazy","WTF"] extension String { func readIt() { print(self) } } funTimes.forEach({ $0.readIt() })//// END EDITJust do this:for view in sel..
For-In LoopsYou use the for-in loop to iterate over a sequence, such as ranges of numbers, items in an array, or characters in a string.This example prints the first few entries in the five-times table:for index in 1...5 { print("\(index) times 5 is \(index * 5)")}// 1 times 5 is 5// 2 times 5 is 10// 3 times 5 is 15// 4 times 5 is 20// 5 times 5 is 25The sequence being iterated over is a range ..
Try this:var checked = [Bool]() // Have an array equal to the number of cells in your table func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! UITableViewCell //configure you cell here. if !checked[indexPath.row] { cell.accessoryType = .None } else if checked[indexPath.r..
let aString: String = "This is my string" let newString = aString.stringByReplacingOccurrencesOfString(" ", withString: "+", options: NSStringCompareOptions.LiteralSearch, range: nil)And as noted by @cprcrack below, the options and range parameters are optional, so if you don't want to specify string comparison options or a range to do the replacement within, you only need the following.let aStr..