CS193Pからダウンロードされたフォトマニアアプリは空のテーブルビューを表示しています

StackOverflow https://stackoverflow.com//questions/9653216

  •  11-12-2019
  •  | 
  •  

質問

スタンフォードIOSコースからこのアプリをダウンロードしました。私は自分のFlickr APIキーを持っていて、Flickrapikey.hに入れるが、それはまだ空の写真家のテーブルビューを与えます。 それが関連しているかどうかはかなりわからないが、それらのログメッセージを手に入れました:

2012-03-11 09:18:46.848フォトマニア[23748:1E03] NSFILECOORDINATOR:驚くべきサーバーエラーがシグナリングされました。詳細:接続無効

役に立ちましたか?

解決

@litov Yes, you can indeed do that, although in situations like this I find it much easier to just delete the App from the iPhone/iPad or the simulator; the database file will then get deleted as well.

他のヒント

I found the problem. If anyone else is facing that problem, here is the solution (in my case): The app only downloads data if the file is not created yet, so the first time I ran it, I didn't put the flickr key yet, so it created the file with no data. When I ran the app again with the key, it never downloaded the data from flickr because it already had the file (with no data.

Here is the code I changed in PhotographersTableViewControler.m

- (void)useDocument
{
    if (![[NSFileManager defaultManager] fileExistsAtPath:[self.photoDatabase.fileURL path]]) {
        // does not exist on disk, so create it
        [self.photoDatabase saveToURL:self.photoDatabase.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) {
            [self setupFetchedResultsController];
            [self fetchFlickrDataIntoDocument:self.photoDatabase];

        }];
    } else if (self.photoDatabase.documentState == UIDocumentStateClosed) {
        // exists on disk, but we need to open it
        [self.photoDatabase openWithCompletionHandler:^(BOOL success) {
            [self setupFetchedResultsController];
            //the next line is the only one I changed!!!!!!
            [self fetchFlickrDataIntoDocument:self.photoDatabase];
        }];
    } else if (self.photoDatabase.documentState == UIDocumentStateNormal) {
        // already open and ready to use
        [self setupFetchedResultsController];
    }
}

After the first time you can delete that line. I hope someone can learn from my mistake.

Litov, it looks like your solution will fetch the data again every time. I'm guessing you aren't getting any duplicates because I think the implementation of fetchFlickrData... is checking for existing records by unique id and only loading those not already loaded.

Nonetheless, it's going to fetch the data from Flickr every time you start up the App, which is slow.

However, since you know that the problem was that you werent set up properly for the first run, you can fix that without this hack: I had a similar problem with a project based on this demo, and I solved it by deleting the database file from the simulator.

You can do that in the file system by going into ~/Library/Application Support/iPhone Simulator/5.1/Applications/ and doing "rm -fr" on the database (it will be a directory with the name you gave it. Note that the "5.1" in that path depends on which version of the simulator you're running, and the will be a directory with a big, unreadable GUID name, but you can cd into several of them and see which one has your .app.

Much easier still: simply delete your app from the simulator (the same way you would from the iPhone/Pad: hold the icon down then click the X) which will take the document with it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top