我正在使用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。 –