Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if aStream == inputStream {
- var dataBuffer = Array<UInt8>(repeating: 0, count: 1024)
- var len: Int
- while (inputStream?.hasBytesAvailable)! {
- len = (inputStream?.read(&dataBuffer, maxLength: 1024))!
- if len > 0 {
- let output = String(bytes: dataBuffer, encoding: .utf8)
- if nil != output {
- // print("server said: \(output ?? "")")
- // isOnlinePresented = true
- let msg = output
- let msgTest = msg!.split(separator: ";")
- let str2 = msg!.replacingOccurrences(of: msgTest[0]+";", with: "")
- let str3 = str2.replacingOccurrences(of: " ", with: "")
- print(str3)
- let data = Data(str3.utf8)
- do {
- // make sure this JSON is in the format we expect
- let json = try JSONSerialization.jsonObject(with: data)
- print(json)
- } catch let error as NSError {
- print("Failed to load: \(error.localizedDescription)")
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement