我正在使用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
在ServerDatabase
類的Select
方法,我發送serizalized天窗查詢變量到服務器內的請求。 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年每個表2000中的數據。
我在這裏遇到了兩個問題。
- 得到一些表格數據(5000行表格等)後,程序會多次導致memorv警告並退出。
- 從服務器獲取2000行表格太慢。有時需要1分鐘。
如何管理或解決這些問題? 有什麼建議嗎?
聽起來對我來說,就像你需要找到一種方法來從你的查詢中檢索匹配條目的一個子集(當用戶在表格中滾動或拉動來刷新時,你可以檢索到其他匹配項)。您(或數據庫管理員)是否有辦法將該API或功能置於您的iOS應用程序的使用位置? –
對於離線工作,我需要從服務器拉出所有數據庫,並且我需要使用.net服務器,因爲安全和限制而獲取表和內容。不幸的是,我的應用沒有API。 –