sorunu çözdüm yapıya ait kodları aşağıda paylaşıyorum konu başlığından bakıp ilgilenen arkadaşlar için.. :
import UIKit
class ViewController: UIViewController, NSURLConnectionDataDelegate{
@IBOutlet weak var progressView: UIProgressView!
@IBOutlet weak var webView: UIWebView!
var connectionManager: NSURLConnection?
var downloadedMutableData: NSMutableData?
var urlResponse: NSURLResponse?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.downloadedMutableData = NSMutableData()
let urlRequest = NSURL(string: "
http://www.apple.com");
let cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData;
let request = NSMutableURLRequest(URL: urlRequest!, cachePolicy:cachePolicy, timeoutInterval: 60.0);
self.connectionManager = NSURLConnection(request: request, delegate: self);
self.webView.loadRequest(request);
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Delegate Methods
func connection(connection: NSURLConnection, didReceiveResponse response: NSURLResponse) {
print("\(response.expectedContentLength)")
self.urlResponse = response
}
func connection(connection: NSURLConnection, didReceiveData data: NSData) {
self.downloadedMutableData!.appendData(data)
self.progressView.progress = Float32( Double(100.0) / Double(self.urlResponse!.expectedContentLength) * Double(self.downloadedMutableData!.length) / Double(100.0))
if self.progressView.progress == 1 {
self.progressView.hidden = false
} else {
self.progressView.hidden = false
}
print("%.0f%")
}
func connectionDidFinishLoading(connection: NSURLConnection) {
print("Finished")
//self.imageView.image = UIImage(data: self.downloadedMutableData!)
}
}