             }
         }
         
-        if i + 1 >= arr.count {
+        if i + 1 >= messageCharacters.count {
             return SocketPacket(type: type, id: id ?? -1,
                 nsp: nsp ?? "/", placeholders: placeholders)
         }
         
-        let next = String(arr[i + 1])
+        let next = String(messageCharacters[i + 1])
         
         if Int(next) != nil {
             var c = ""
-            while ++i < arr.count {
-                if let int = Int(String(arr[i])) {
+            while ++i < messageCharacters.count {
+                if let int = Int(String(messageCharacters[i])) {
                     c += String(int)
                 } else {
                     --i

    
    // Parses data for events
    static func parseData(data: String) -> AnyObject? {
        var err: NSError?
        let stringData = data.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
        let parsed: AnyObject?
        
        do {
            parsed = try NSJSONSerialization.JSONObjectWithData(stringData!,
                        options: NSJSONReadingOptions.MutableContainers)
        } catch let error as NSError {
            err = error
            parsed = nil
        }
        
        if err != nil {
            // println(err)
            return nil
        }
        
        return parsed
    }
    
    // Parses messages recieved

import Foundation

class SocketParser {
    
    private static func isCorrectNamespace(nsp: String, _ socket: SocketIOClient) -> Bool {
        return nsp == socket.nsp
    }
