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 playerLayer = AVPlayerLayer(player: player) | |
playerLayer.frame = self.videoView.bounds //bounds of the view in which AVPlayer should be displayed | |
playerLayer.videoGravity = .resizeAspect |
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 asset = AVAsset(url: url) | |
let playerItem = AVPlayerItem(asset: asset) | |
let player = AVPlayer(playerItem: playerItem) |
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 DynamicHeightCollectionView: UICollectionView { | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
if!__CGSizeEqualToSize(bounds.size,self.intrinsicContentSize){ | |
self.invalidateIntrinsicContentSize() | |
} | |
} | |
override var intrinsicContentSize: CGSize { | |
return contentSize | |
} |
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
var arr1 = ["Mumbai", "Bangalore"] | |
var arr2 = arr1 | |
print(address(of: arr1)) //0x608000092e50 | |
print(address(of: arr2)) //0x608000092e50 | |
arr2[0] = "Jaipur" | |
print(address(of: arr1)) //0x608000092e50 | |
print(address(of: arr2)) //0x608000092ea0 |
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
var arr1 = [Address("Mumbai"), Address("Bangalore")] | |
var arr2 = arr1 |
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 Address: Codable | |
{ | |
var city: String? | |
init(_ city: String?) | |
{ | |
self.city = city | |
} | |
} | |
var arr1 = [Address("Mumbai"), Address("Bangalore")] |
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 Person: NSObject, NSCopying | |
{ | |
var name: String? | |
var address: Address? | |
init(_ name: String?, _ address: Address?) | |
{ | |
self.name = name | |
self.address = address | |
} |
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 Address: NSObject, NSCopying | |
{ | |
var city: String? | |
init(_ city: String?) | |
{ | |
self.city = city | |
} | |
func copy(with zone: NSZone? = nil) -> Any | |
{ |
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 Address | |
{ | |
var city: String? | |
init(_ city: String?) | |
{ | |
self.city = city | |
} | |
} | |
var a1 = Address("Mumbai") |
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
var arr1 = ["John", "Stefen", "Caroline"] | |
var arr2 = arr1 | |
print(arr1) //John, Stefen, Caroline | |
print(arr2) //John, Stefen, Caroline | |
arr2.removeLast() | |
arr2[0] = "Maddy" | |
print(arr1) //John, Stefen, Caroline |