Why does Cocoa return an empty string occasionally?

后端 未结 2 1662
春和景丽
春和景丽 2021-01-06 02:52

I have some code in my application that looks something like this:

char *hash = (char*) sqlite3_column_text(get_bookmark, 0);
NSString* postHash = [NSString          


        
相关标签:
2条回答
  • 2021-01-06 03:23

    However I find that postHash is an empty string (@"") for some users some of the time.

    Can anyone explain why?

    Because hash is an empty string (hash[0] == '\0').

    0 讨论(0)
  • 2021-01-06 03:30

    I finally found the solution to this. I'm going to give Peter the accepted answer as he is right but the reason that I was getting an empty string is... interesting.

    The database is populated correctly. The query is also correct. The difference between my phone and my users is that they have jail broken handsets. And apparently jail broken iPhones sometimes use a different version of SQLite than found in shipping versions of iPhone OS.

    The change in version exposed a bug in my code that caused one of the parameters to be set incorrectly and sqlite3_column_text to return an empty string.

    0 讨论(0)
提交回复
热议问题