iphone sql - 读取时数据损坏/丢失
我正在使用 SQL 在我的应用程序中存储数据。我读取应用程序委托中的数据并将其存储在数组中,如下所示。
(首先我从数据库中读取并存储在 FlashcardSet 中,然后是这个)
// Add the flashcardSet to the main Array
[mainSetsArray addObject:aFlashcardSet];
在下一个视图中,我然后从应用程序委托复制数据。
flashcardsAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
self.setsArray = delegate.mainSetsArray;
然后我将一个对象从集合传递到最终视图。
cardDetailViewController.thisCardSet = [setsArray objectAtIndex:row];
问题是,当我在最终视图中读取数据并用于设置应用程序崩溃的 UI 元素时,代码可以在第二阶段期间硬编码的数据正常工作,并且数据库数据在第二阶段期间显示正常(填充表)看法)。我已经尝试在所有阶段输出数据,并且在最终视图之前它都是正确的,直到最终视图崩溃或显示不正确的值(文件名或随机字母而不是实际文本)。
我还尝试读取最终视图中的数据库数据并将其设置为 thisCardSet 但它仍然遇到同样的问题。
有什么想法吗?
谢谢。
I'm using SQL to store data in my application. I read data in the app delegate and store it in an array like so.
(First I read from the database and store in aFlashcardSet and then this)
// Add the flashcardSet to the main Array
[mainSetsArray addObject:aFlashcardSet];
In my next view I then copy the data from the app delegate.
flashcardsAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
self.setsArray = delegate.mainSetsArray;
Then I pass one object from the set to the final view.
cardDetailViewController.thisCardSet = [setsArray objectAtIndex:row];
The problem is when I read the data in the final view and use to set UI elements the app crashes, the code works fine with data hard coded during the second phase and the database data is shown fine during the second phase (to populate a table view). I've tried outputting the data at all stages and it is all correct until the final view where it either crashes or shows incorrect values (file names or random letters rather than the actual text).
I have also tried to read the database data inside the final view and set it to thisCardSet but it still suffers the same problem.
Any ideas?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题出在我的自定义类之一中,我没有使用 self,所以我正在编写。
aString = 字符串;
而不是 -
self.aString = string;
所以我正在丢失数据,感觉真的很愚蠢,但希望它对其他人有帮助=]。
The problem was inside one of my custom classes I wasn't using self, so I was writing.
aString = string;
Rather than -
self.aString = string;
So I was losing data down the line, feel really stupid but hope it help's someone else =].