This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"count": 20, "fitness_disciplines": [{"id": "walking", "name": "Walking"}, {"id": "strength", "name": "Strength"}, {"id": "cycling", "name": "Cycling"}, {"id": "stretching", "name": "Stretching"}, {"id": "running", "name": "Running"}, {"id": "beyond_the_ride", "name": "Floor"}, {"id": "circuit", "name": "Bootcamp"}, {"id": "yoga", "name": "Yoga"}, {"id": "meditation", "name": "Meditation"}, {"id": "cardio", "name": "Cardio"}], "rides": [{"scheduled_start_time": 1565883000, "rating": 0, "difficulty_rating_avg": 0.0, "equipment_tags": [], "difficulty_rating_count": 0, "captions": [], "title": "30 min Power Zone Ride", "is_explicit": false, "live_stream_id": "e571d20a9efc4e34a75a8bb3924acfd7-live", "origin_locale": "en-US", "difficulty_estimate": null, "content_format": "video", "location": "nyc", "original_air_time": 1565882340, "has_closed_captions": false, "pedaling_duration": 1800, "sample_vod_stream_url": null, "extra_images": [], "series_id": "9fde039566054ea499130bed1c289eb3", "studio_peloton_id": "7812b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class myClass { | |
} | |
// the public keyword defines the access control for this class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if let actualInteger = possibleInteger, | |
let actualDouble = actualInteger as? Double { | |
// do stuff with actualInteger | |
// or actualDouble | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if let acutualInteger = possibleInteger, | |
var actualString = possibleString { | |
// do stuff | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func add(firstPossibleInteger: Int?, secondPossibleInteger: Int?) -> Int? { | |
guard let firstNumber = firstPossibleInteger, | |
let secondNumber = secondPossibleNumber | |
else { return nil } // or 0 if you want to return a | |
// non-optional value | |
return (firstNumber + secondNumber) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if let actualDouble = possibleDouble { | |
// do stuff with actualDouble | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if let actualInteger = possibleInteger as? Int { | |
// do stuff with actual integer | |
print(actualInteger) // prints 3 | |
print(possibleInteger) // prints Optional(3) | |
// actualInteger's scope ends here | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomTableViewCell: UITableViewCell { | |
@IBOutlet weak var imageView: UIImageView! | |
@IBOutlet weak var title: UILabel! | |
@IBOutlet weak var subtitle: UILabel! | |
} | |
class TableView: UITableView { | |
func tableView(_ tableView: UITableView, | |
cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCell(with: identifier) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var integerValue = 42 | |
var stringValue = String(describing: 42) | |
var doubleValue = integerValue as! Double | |
var floatValue = Int(stringValue) as? Float | |
var array: [String] = ["eggs", "bacon", "ham", "cheese"] | |
let arrayCount = Double(array.count as? String) | |
var numArray: [Int] = [1, 2, 3, 4, 5] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var integerValue = 42 | |
var stringValue = integerValue as? String |
NewerOlder