Skip to content

Instantly share code, notes, and snippets.

View kmuralidharan91's full-sized avatar
😀

Muralidharan Kathiresan kmuralidharan91

😀
View GitHub Profile
@kmuralidharan91
kmuralidharan91 / CustomTableViewCell.swift
Last active July 24, 2018 18:45
WikiSearch - Demo app on Alamofire with SwiftyJSON
import UIKit
class CustomTableViewCell: UITableViewCell {
@IBOutlet weak var wikiImageView: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var descriptionLabel: UILabel!
@kmuralidharan91
kmuralidharan91 / APIRequestFetcher.swift
Created July 25, 2018 06:00
APIRequestFetcher.swift
import Foundation
import SwiftyJSON
import Alamofire
enum NetworkError: Error {
case failure
case success
}
class APIRequestFetcher {
@kmuralidharan91
kmuralidharan91 / SearchResultsTableViewController.swift
Created July 25, 2018 06:11
UITableViewController with SearchBar
import UIKit
import SwiftyJSON
import Alamofire
import SafariServices
final class SearchResultsTableViewController: UITableViewController {
private var searchResults = [JSON]() {
didSet {
tableView.reloadData()
@kmuralidharan91
kmuralidharan91 / GenerateResources.sh
Created December 14, 2018 07:56
Generate Resources Build Script for SwiftGen
#!/bin/sh
RSROOT=$SRCROOT/CleanAssetsManagementDemo/Resources
"$PODS_ROOT/SwiftGen/bin/swiftgen" \
xcassets -t swift3 "$RSROOT/Assets.xcassets" \
--output "$RSROOT/Assets.swift"
"$PODS_ROOT/SwiftGen/bin/swiftgen" \
switch(expression){
case constant-expression :
statement(s);
break; /* optional */
case constant-expression :
statement(s);
break; /* optional */
/* you can have any number of case statements */
default : /* Optional */
var integer = 3
switch integer {
case 4:
print("Four.")
fallthrough
case 3:
print("Three.")
fallthrough
case 2:
print("Two.")
switch expression {
case expression1:
statement(s)
fallthrough /* optional */
case expression2, expression3: /* we can use , to use same implementation for more than one case */
statement(s)
fallthrough /* optional */
default : /* Optional */
statement(s);
}
switch userNotificationsAuthorizationStatus {
case .notDetermined:
requestPermission()
case .authorized, .denied, .provisional:
// No need to request permission.
print("Didn't request permission for User Notifications")
}
switch userNotificationsAuthorizationStatus {
case .notDetermined:
requestPermission()
case .authorized, .denied, .provisional:
fallthrough
@unknown default:
// No need to request permission.
print("Didn't request permission for User Notifications")
}
public extension Array {
func slice(_ from: Int, count: Int) -> ArraySlice<Element>? {
guard (0 <= from && from < self.count) && (from < from+count && from+count < self.count) else {
return nil
}
return self[from...from+count-1]
}
}