This file contains hidden or 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
let jsonString = """ | |
{ | |
"type":"fruit", | |
"size":{ | |
"width":150, | |
"height":150 | |
}, | |
"title":"Apple", | |
"url":"https:\\/\\/www.fruits.com\\/apple", | |
"isSample":true, |
This file contains hidden or 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
struct Photo: Codable | |
{ | |
//...Other properties (described in Code Snippet - 1)... | |
//This property is not included in the CodingKeys enum and hence will not be encoded/decoded. | |
var format: String = "png" | |
enum CodingKeys: String, CodingKey | |
{ | |
case title = "name" |
This file contains hidden or 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
let jsonString = """ | |
{ | |
"type":"fruit", | |
"size":{ | |
"width":150, | |
"height":150 | |
}, | |
"name":"Apple", | |
"link":"https:\\/\\/www.fruits.com\\/apple", | |
"isSample":true, |
This file contains hidden or 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 City: NSObject, NSCoding | |
{ | |
var name: String? | |
var id: Int? | |
required init?(coder aDecoder: NSCoder) | |
{ | |
self.name = aDecoder.decodeObject(forKey: "name") as? String | |
self.id = aDecoder.decodeObject(forKey: "id") as? Int | |
} |
This file contains hidden or 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
struct Photo: Codable | |
{ | |
var title: String | |
var size: Size | |
enum CodingKeys: String, CodingKey | |
{ | |
case title = "name" | |
case size | |
} |
This file contains hidden or 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
{ | |
"size":{ | |
"width":150, | |
"height":150 | |
}, | |
"name":"Apple" | |
} |
This file contains hidden or 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
{ | |
"title":"Apple", | |
"width":150, | |
"height":150 | |
} |
This file contains hidden or 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
struct Photo | |
{ | |
var title: String | |
var size: Size | |
enum CodingKeys: String, CodingKey | |
{ | |
case title = "name" | |
case width | |
case height |
This file contains hidden or 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 collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] | |
{ | |
let item = self.items[indexPath.row] | |
let itemProvider = NSItemProvider(object: item as NSString) | |
let dragItem = UIDragItem(itemProvider: itemProvider) | |
dragItem.localObject = item | |
return [dragItem] | |
} |
This file contains hidden or 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 collectionView(_ collectionView: UICollectionView, dropSessionDidUpdate session: UIDropSession, withDestinationIndexPath destinationIndexPath: IndexPath?) -> UICollectionViewDropProposal | |
{ | |
if session.localDragSession != nil | |
{ | |
if collectionView.hasActiveDrag | |
{ | |
return UICollectionViewDropProposal(operation: .move, intent: .insertAtDestinationIndexPath) | |
} | |
else | |
{ |