Reputation: 3945
I want to load data from Web service while showing the Splash Screen. In the initial Screen I need to display those data. How can I do this ? From where I need to call the webservice?
Upvotes: 2
Views: 2197
Reputation: 2097
Take one NSTimer at time of launch splash screen.
Put your splash screen in sleep mode.
Store parse data in array.
In the below method of parser
-(void)parserDidEndDocument:(NSXMLParser *)parser
{
if([array count]>0){
//load view whatever you want and display fresh data
}else{
//Alert msg Data not available or display old data if available in database.
}
}
Upvotes: 0
Reputation: 49710
you must call webservice in your Appdelegate and create globle NSmutableArray
and use this array in your app
with xml parsiong
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSString *path = [NSString stringWithFormat:your url path];
NSLog(@"path= %@",path);
[self parseXMLFileAtURL:path];
}
-(void)parseXMLFileAtURL:(NSString*)URL
{
NSURL *url = [NSURL URLWithString:URL];
RssParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
[RssParser setDelegate:self];
[RssParser setShouldProcessNamespaces:NO];
[RssParser setShouldReportNamespacePrefixes:NO];
[RssParser setShouldResolveExternalEntities:NO];
[RssParser parse];
}
-(void)parserDidStartDocument:(NSXMLParser *)parser
{
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
}
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
{
}
-(void)parserDidEndDocument:(NSXMLParser *)parser
{
}
Upvotes: 3
Reputation: 2257
Do this in AppDelegate API
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Make a webservice call in this method. It is the first method that is invoked after main()
Upvotes: 0