Skip to content

Instantly share code, notes, and snippets.

@aGupieWare
aGupieWare / swift_client_background_queue.txt
Created November 14, 2014 21:49
Swift client, background queue . . .
let backgroundQueue : dispatch_queue_t = dispatch_queue_create("com.aGupieWare.SwiftNetworking.backgroundQueue", nil)
@aGupieWare
aGupieWare / swift_client_dispatch_sync.txt
Created November 14, 2014 21:52
Swift client, dispatch async . . .
// endpoint of corresponding supply item image //
let urlString : String = supplyItem.bsn_image!
dispatch_async(self.backgroundQueue, { () -> Void in
/* capture the index of the cell that is requesting this image download operation */
var err : NSError?
/* get url for image and download raw data */
if err == nil {
@aGupieWare
aGupieWare / swift_client_captured_index.txt
Created November 14, 2014 21:55
Swift client, captured index . . .
var capturedIndex : NSIndexPath? = indexPath.copy() as? NSIndexPath
@aGupieWare
aGupieWare / swift_client_image_data.txt
Created November 14, 2014 21:57
Swift client, image data . . .
let url = NSURL(string: urlString)!
var imageData : NSData? = NSData(contentsOfURL: url, options: NSDataReadingOptions.DataReadingMappedIfSafe, error: &err)
@aGupieWare
aGupieWare / swift_client_item_image.txt
Created November 14, 2014 21:59
Swift client, item image . . .
let itemImage = UIImage(data:imageData!)
@aGupieWare
aGupieWare / swift_client_current_index.txt
Created November 14, 2014 22:00
Swift client, current index . . .
let currentIndex = tableView.indexPathForCell(cell)
@aGupieWare
aGupieWare / swift_client_compare_index.txt
Created November 14, 2014 22:02
Swift client, comapre index . . .
currentIndex?.item == capturedIndex!.item
@aGupieWare
aGupieWare / swift_client_item_view_snippet.txt
Created November 17, 2014 02:56
Swift client, item view snippet . . .
@IBOutlet weak var bsn_imageView: UIImageView!
@IBOutlet weak var bsn_textView: UITextView!
var bsn_plumbingItem: PlumbingSupplyItem?
var bsn_capturedImage: UIImage?
var urlSession = NSURLSession.sharedSession()
let backgroundQueue : dispatch_queue_t = dispatch_queue_create("com.aGupieWare.SwiftNetworking.backgroundQueue", nil)
@aGupieWare
aGupieWare / swift_client_default_navigation_code.txt
Created November 17, 2014 03:05
Swift client, default navigation code . . .
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@aGupieWare
aGupieWare / swift_client_prepare_for_segue.txt
Created November 17, 2014 03:07
Swift client, final prepare for segue . . .
let destViewController = segue.destinationViewController as PlumbingSupplyItemDescriptionViewController
let selectedCell = sender as UITableViewCell
let selectedIndex = self.tableView.indexPathForCell(selectedCell)
destViewController.bsn_plumbingItem = self.dataSource[selectedIndex!.row]
destViewController.bsn_capturedImage = selectedCell.imageView.image