在Nsstream中调用segue时出错

时间:2015-10-04 15:03:41

标签: ios swift nsstream

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<Test.gameView_ViewController: 0x145669e10>) has no segue with identifier 'backSegue''  

***首先抛出调用堆栈:
(0x1842c0f5c 0x198eb3f80 0x189b7b774 0x10005c5a0 0x100054b14 0x101151d70 0x101151d30 0x101157780 0x184278258 0x1842760c0 0x1841a4dc0 0x18f2f8088 0x18987ef60 0x10005d0c0 0x1996de8b8)
libc ++ abi.dylib:以NSException类型的未捕获异常终止

这是代码:

func stream(aStream: NSStream, handleEvent eventCode: NSStreamEvent) {  
    switch(eventCode){  


    case NSStreamEvent.HasBytesAvailable:  

        var buffer = [UInt8](count: 4096, repeatedValue: 0)  


        if ( aStream == GlobalVariables.inputStream){  

            while (GlobalVariables.inputStream!.hasBytesAvailable){  
                let len = GlobalVariables.inputStream!.read(&buffer, maxLength: buffer.count)  
                if(len > 0){  
                    let output = NSString(bytes: &buffer, length: buffer.count, encoding: NSUTF8StringEncoding)!.stringByTrimmingCharactersInSet(  
                        NSCharacterSet.whitespaceAndNewlineCharacterSet())  
                    if (output != ""){  
                        /  

                        /  
                        var buf = UnsafeMutablePointer<CChar>(buffer)  

                        var bufString: String = String.fromCString(buf)!  

                        if ((delegate) != nil){  
                            delegate!.dataReceived(bufString)  
                        }  

                    }  
                }  
            }  


        }  


        break  

    case NSStreamEvent.OpenCompleted:  

        break  

    default: break  

    }  


}  

1 个答案:

答案 0 :(得分:0)

显然,你没有在正确的对象上调用你的segue。请确保您在正确的对象上调用performSegueWithIdentifier:函数。例如:

这是正确的:

[self performSegueWithIdentifier:@"backSegue" sender:self];

这是不正确的:

[self.navigationController performSegueWithIdentifier:@"backSegue" sender:self];