Ich muss eine Datei in RubyMotion herunterladen und dekomprimieren. Ich habe versucht, nach Beispielen zu suchen, konnte aber nichts von diesem Prozess finden.Rubymotion: Zip-Datei herunterladen und extrahieren in iOS
Ich habe eine Variable (@Datei), die alle Daten aus der Anfrage ist. Ich muss diese Daten in eine Datei schreiben und dann entpacken, die unkomprimierten Daten persistieren und die tmp komprimierte Datei löschen.
Hier ist, was ich bisher:
class LoadResourcesViewController < UIViewController
def viewDidAppear(animated)
@loading_bar = retrieve_subview_with_tag(self, 1)
req=NSURLRequest.requestWithURL(NSURL.URLWithString("#{someurl}"))
@connection = NSURLConnection.alloc.initWithRequest req, delegate: self, startImmediately: true
end
def connection(connection, didFailWithError:error)
p error
end
def connection(connection, didReceiveResponse:response)
@file = NSMutableData.data
@response = response
@download_size = response.expectedContentLength
end
def connection(connection, didReceiveData:data)
@file.appendData data
@loading_bar.setProgress(@file.length.to_f/@download_size.to_f)
end
def connectionDidFinishLoading(connection)
#create tmp file
#uncompress .tar, .tar.gz or .zip
#presist uncompresssed files and delete original tmp file
puts @file.inspect
@connection.release
solutionStoryboard = UIStoryboard.storyboardWithName("Master", bundle:nil)
myVC = solutionStoryboard.instantiateViewControllerWithIdentifier("Main3")
self.presentModalViewController(myVC, animated:true)
end
end
Jede Hilfe oder Beispiele wäre großartig!
hat mir geholfen, ein ähnliches Problem zu lösen, danke für Ihre Lösung! – sbauch