-3

我正在为我的应用创建登录和注册。每次运行此代码时,我都会收到此错误:

#import <UIKit/UIKit.h>

#import "THRAppDelegate.h"

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([THRAppDelegate class]));
    }
}

谁能告诉我这是什么意思?我相信它发生在服务器端(PHP)

我不断收到的 JSON 响应也是错误:False

这是php代码:

function registerUser($email, $name, $username, $password){

    $uuid               = uniqid('', true);
    $hash               = hashSSHA($password);
    $encrypted_password = $hash["encrypted"]; //encrypted password
    $salt               = $hash["salt"]; //salt password


$register = query("SELECT email FROM users WHERE email='$email' limit 1");  

    if (count($register['result'])>0) {

        errorJson('This email is already registered. Try to login or recover your password.');
    }



    //try to register the user

$result  = query("INSERT INTO users(unique_id, name, email, username, encrypted_password, salt) VALUES('$uuid', '$name', '$email','$username', '$encrypted_password', '$salt', NOW())");    
    if (!$result['error']) {
        //success
        login($email, $password);

    } else {
        //error
        //errorJson('Sorry, something went wrong :( . Please try again later.');
        errorJson(mysql_error());
    }

}

function login($email, $password){

    $result = query("SELECT uid, email FROM users WHERE email ='%s' AND password ='%s' limit 1", $email, $password);

    if (count($result['result'])>0) {


            $salt               = $result['salt'];
            $encrypted_password = $result['encrypted_password'];
            $hash               = checkhashSSHA($salt, $password);

            //checking for password equality
            if ($encrypted_password == $hash) {
                //user authentication details are correct
                return $result;
                //authorized
                $_SESSION['uid'] = $result['result'][0]['uid'];

                print json_encode($result);
            }

    } else {
        //not authorized
        errorJson('Wrong Email and password combination.');
    }

}

function hashSSHA($password){

        $salt = sha1(rand());
        $salt = substr($salt, 0,10);
        $encrypted = base64_encode(sha1($password . $salt, true) . $salt);
        $hash = array("salt" => $salt, "encrypted" => $encrypted);
        return $hash;
    }

/*
    *Decrypting password
    *#param salt. pasword
    returns hash string
    */
function checkhashSSHA($salt, $password){

        $hash = base64_encode(sha1($password.$salt, true) . $salt);
        return $hash;
    }

Xcode 错误

2012-10-11 15:04:42.528 Thryfting[1457:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean isEqualToString:]: unrecognized selector sent to instance 0x1883964'
*** First throw call stack:
(0x1752012 0x1577e7e 0x17dd4bd 0x1741bbc 0x174194e 0x6184af 0x618674 0x8b0706 0x8be578 0x8beb50 0x1b5fb 0x1ce4c 0x1e6fb 0xed99 0x1f0753f 0x1f19014 0x1f097d5 0x16f8af5 0x16f7f44 0x16f7e1b 0x2c827e3 0x2c82668 0x4bf65c 0x2bad 0x2ad5 0x1)
libc++abi.dylib: terminate called throwing an exception
4

2 回答 2

0

您可以通过 Zombie 对象跟踪您的代码:

⌥</kbd>⌘</kbd>R

选择“诊断”选项卡并单击“启用僵尸对象”:

点击

这会将释放的对象转换为 NSZombie 实例,在再次使用时会打印控制台警告。这是一种调试辅助工具,可以增加内存使用(没有真正释放对象),但可以改进错误报告。

一个典型的情况是当你过度释放一个对象并且你不知道是哪一个时:

  • 与僵尸:-[UITextView release]: message sent to deallocated instance
  • 没有僵尸:EXC_BAD_ACCESS

于 2012-10-11T19:05:25.747 回答
0

所以,据我所知,你的错误是

[__NSCFBoolean isEqualToString:]: unrecognized selector....

这意味着,在您的代码中的某处(无法告诉您在哪里,因为您没有提供它)您正在向一个不是 NSString 的对象发送 isEqualToString 消息。

请您快速搜索一下,看看您在哪里发送该消息?可能是您正在读取一个布尔值,但将其视为 NSString。请检查您的代码,并确认您在发送该消息之前检查了数据类型。

请提供可能发生这种情况的代码。

于 2012-10-11T21:06:47.803 回答