私はIOSアプリケーションに取り組んでいます。このアプリケーションはサーバーに接続し、各テーブルのすべての行を取得します。私のアプリのいくつかのコードは以下の通りです;
for(NSString* tableName in dtTables)
{
long PageCount=2000;
long rowCount=0;
long currCount=0;
.
.
rowCount= [(NSNumber*)[row objectAtIndex:0] longValue]; // count row in the table
while (currCount<rowCount)
{
long Next=MIN(PageCount,rowCount-currCount);
SkylightQuery* query = [ServerQueryGenerator GenerateSelect:tableName :nil :nil :nil :nil :false :nil];
query.LimitBegin=currCount;
query.LimitLenght= Next;
NSMutableDictionary* table = [[ServerDatabase SI] Select:query];
.
.
currCount +=Next;
} // while
}//for
Select
クラスのメソッドで、ServerDatabase
シリアル化された Skylight クエリ変数内のリクエストをサーバーに送信します。Command
変数は、シリアル化されたサーバー リクエストを含む文字列を保持します。
NSURLRequest *Request = [NSURLRequest requestWithURL:[NSURL URLWithString:[command stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30];
NSURLResponse *Response = nil;
NSError *err = nil;
NSData *response = [NSURLConnection sendSynchronousRequest: Request returningResponse: &Response error: &err];
サーバーには70のテーブルがあります。100 レコードのテーブルもあれば、10000 レコードのテーブルもあります。だから私は2000年ごとに各テーブルのデータを取得しています.
ここで直面した問題は 2 つあります。
- いくつかのテーブルデータ(5000行のテーブルなど)を取得した後、プログラムは memorv 警告を数回発生させて終了します。
- サーバーからテーブルの 2000 行を取得するのは遅すぎます。場合によっては1分かかります。
これらの問題をどのように管理または解決できますか? なにか提案を?