Skip to content

Instantly share code, notes, and snippets.

Avatar

Payal Gupta pgpt10

  • Delhi
View GitHub Profile
View VideoStreaming2.swift
let playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = self.videoView.bounds //bounds of the view in which AVPlayer should be displayed
playerLayer.videoGravity = .resizeAspect
View VideoStreaming1.swift
let asset = AVAsset(url: url)
let playerItem = AVPlayerItem(asset: asset)
let player = AVPlayer(playerItem: playerItem)
View DynamicHeightCollectionView.swift
class DynamicHeightCollectionView: UICollectionView {
override func layoutSubviews() {
super.layoutSubviews()
if!__CGSizeEqualToSize(bounds.size,self.intrinsicContentSize){
self.invalidateIntrinsicContentSize()
}
}
override var intrinsicContentSize: CGSize {
return contentSize
}
View DeepShallow7.swift
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
View DeepShallow6.swift
var arr1 = [Address("Mumbai"), Address("Bangalore")]
var arr2 = arr1
View DeepShallow5.swift
class Address: Codable
{
var city: String?
init(_ city: String?)
{
self.city = city
}
}
var arr1 = [Address("Mumbai"), Address("Bangalore")]
View DeepShallow4.swift
class Person: NSObject, NSCopying
{
var name: String?
var address: Address?
init(_ name: String?, _ address: Address?)
{
self.name = name
self.address = address
}
View DeepShallow3.swift
class Address: NSObject, NSCopying
{
var city: String?
init(_ city: String?)
{
self.city = city
}
func copy(with zone: NSZone? = nil) -> Any
{
View DeepShallow2.swift
class Address
{
var city: String?
init(_ city: String?)
{
self.city = city
}
}
var a1 = Address("Mumbai")
View DeepShallow1.swift
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
You can’t perform that action at this time.