.
navigationController?.navigationBar.isTranslucent = false
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.barStyle = .black
navigationController?.navigationBar.barTintColor = UIColor.red
navigationController?.navigationBar.shadowImage = UIImage()
title = "User profile";
let searchBar = UISearchBar()
searchBar.placeholder = "Search"
searchBar.frame = CGRect(x: 0, y: 0, width: (navigationController?.view.bounds.size.width)!, height: 64)
searchBar.barStyle = .default
searchBar.isTranslucent = false
searchBar.barTintColor = UIColor.red
searchBar.backgroundImage = UIImage()
view.addSubview(searchBar)
var app = require('express')()
var server = require('http').Server(app)
var io = require('socket.io')(server)
server.listen(3000)
io.on('connection', function(socket) {
socket.on('comment', function(data) {
io.emit('comment', data)
})
}
socket.on("comment") {[weak self] data ,ack in
// получаешь комменты
}
for (name, attr) in newManagedObject.entity.attributesByName {
let attrType = attr.attributeType // NSAttributeType enumeration for the property type
let attrClass = attr.attributeValueClassName ?? "unknown"
print(name, "=", newManagedObject.valueForKey(name), "type =", attrClass)
}
func setCookies() -> HTTPCookie? {
let cookieProperties: [HTTPCookiePropertyKey : Any] = [HTTPCookiePropertyKey.name: "PerfectCookie",
HTTPCookiePropertyKey.value: "Perfect is awesome",
HTTPCookiePropertyKey.domain: "localhost",
HTTPCookiePropertyKey.secure: false]
return HTTPCookie(properties: cookieProperties)
}
let string = "Any String"
let style = NSMutableParagraphStyle()
style.alignment = .right
let attributes = [
NSForegroundColorAttributeName: UIColor.white,
NSParagraphStyleAttributeName: style
]
let attributedString = NSMutableAttributedString(string: string, attributes: attributes)
textView.attributedText = attributedString
record all;
player.addObserver(self, forKeyPath: "status", options: .new, context: nil)
// catch changes to status
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if keyPath == "status" {
// do something
}
}
func getJSON(rs: String, tx: String, completion: @escaping ((String) -> Void)) {
DispatchQueue.main.async { [weak self] in
guard let `self` = self else { return }
let inputURL = self.inputURL.text
let link = inputURL?.components(separatedBy: "wall")
let baseURL = "https://api.vk.com/method/wall.getById?posts=\(link![1])&access_token=87c166c356c35f6d835048af60d84014fa57d4eae&v=5.64"
let url = URL(string: baseURL)
let request = NSURLRequest(url: url! as URL)
let session = URLSession(configuration: .default)
session.dataTask(with: request as URLRequest) { (data, response, error) -> Void in
if error == nil {
let swiftyJSON = JSON(data: data!)
let response = swiftyJSON[rs].arrayValue
for tobject in response {
completion(tobject[tx].stringValue)
}
}
}
}
}