How to continually call a function using NSThread in ios [closed] - ios

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I'm writing a program for parsing xml file I need to continually read the file that means if any change happens to the xml file at run time it must shown in the simulator also
I tried
NSThread *myThread =[[NSThread alloc]initWithTarget:self selector:#selector(doParsing) object:nil];
[myThread start];
and it calls the xml file but its not showing the change .How can I achieve that

Possibly something like:
NSThread *myThread =[[NSThread alloc]initWithTarget:self selector:#selector(callTimer) object:nil];
[myThread start];
- (void)callTimer
{
[NSTimer scheduledTimerWithTimeInterval:10.0
target:self
selector:#selector(doParsing)
userInfo:nil
repeats:YES];
}
- (void)doParsing
{
//Do the stuff here
}

Related

Best way to schedule a background task for iOS? [duplicate]

This question already has answers here:
iOS Run Code Once a Day
(5 answers)
Closed 9 years ago.
I have an app right now that allows a user to pull information from a website. I unfortunately don't have any access to an API for the site, it's just something I screen scrape. Ideally the user will scrape the information once a day from the site.
Currently I set a time and use performFetchWithCompletionHandler. When performFetchWithCompletionHandler gets called, it checks the time that was set and if the time is the current time, it will perform the scraping. Unfortunately, performFetchWithCompletionHandler doesn't work this way (I can't guarantee it will fire during the hour & minute that the user specified). Is there a way to let my app run in the background and scrape a website at a designated interval?
this may be helpful to you...
First declare ,
NSTimer *timerAppBG;
in your AppDelegate.h file....
-> Please put bellow all methods in AppDelegate.m File...
- (void)applicationWillResignActive:(UIApplication *)application
{
timerAppBG = [NSTimer scheduledTimerWithTimeInterval:60.0f target:self selector:#selector(applicationWillResign) userInfo:nil repeats:YES];
}
- (void) applicationWillResign
{
NSLog(#"About to lose focus");
//Write your code here...
[self myVcInitMethod];
}
- (void) myVcInitMethod
{
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:#selector(applicationWillResign)
name:UIApplicationWillResignActiveNotification
object:NULL];
}
Thanks.

Creating an Asynchronous Serial queue in ios [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I need to create a queue that executes asynchronously, but the order in which the tasks execute must be serial
dispatch_queue_t queue;
queue = dispatch_queue_create("com.test.app", NULL); //create a serial queue can either be null or DISPATCH_QUEUE_SERIAL
dispatch_async(queue,
^{
//Mycode for doing background http
}
I think that you are doing it correctly,
dispatch_queue_t queue;
queue = dispatch_queue_create("com.test.app", NULL); //create a serial queue can either be null or DISPATCH_QUEUE_SERIAL
dispatch_async(queue,
^{
task1;
task2;
...
all this tasks wil be done done sequentially
}

how to get a field press event in blackberry [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
how to get a field press event in blackberry。
I write a component extends Field class , want to get a press event( press down still not press up ) .
please help me.
You can override this method:
protected boolean keyDown(int keycode, int time)
About the key up presses, there's a keyUp which is the method you should override to perform an action when the key is released instead of pressed (you can press and hold, and the action doesn't normally get fired until released). However, the OS doesn't callback on key up events unless it is explicitly told to do so by your app, for performance reasons.
You can overide keydown method of any field variable , or you can override navigationClick method of click
public ButtonField btn = new ButtonField("Hello");
protected boolean navigationClick(int status, int time)
{
Field f1 = getFieldWithFocus().getLeafFieldwithFocus()
if(f1 == btn)
{
<Perform your business logics>
}
Thanks

client sending two messagese to servlet successivley using url object [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
My servlet on receiving first request from client:
//1.
ObjectInputStream in=new ObjectInputStream(req.getInputStream());
String r=(String) in.readObject();
in.close();
ObjectOutputStream writer = new ObjectOutputStream(resp.getOutputStream());
writer.writeObject(pk);
writer.close();
//ON receiving second request:
//2.
ObjectInputStream in1=new ObjectInputStream(req.getInputStream());
String s=(String) in1.readObject();
in1.close();
OutputStreamWriter writer1 = new OutputStreamWriter(resp.getOutputStream());
writer1.write(reverseStr);
writer1.close();
But on both request only 1. is getting executed. why?
I asked this question without actually studying servlets. A servlet's method(doPost(),doGet() etc) are each called time a request is made to the servlet. Only the init() method is initialized or executed only once.
So each time a call is made to the above servlet, it starts executing from #line1.

Continue Checking Method [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a method that starts my game (startGame). I call it in viewDidLoad ([self startGame];). The problem is, that the start game method checks to see if an object has moved before it starts the game. The setup I have right now only calls the method once and doesn't check it again which means my game never starts. Any ideas on how I can continue checking the method UNTIL the game starts, and then stop checking it?
Thanks. Happy 2012
there are a few things you can do.. one of the easiest would be to use a NSTimer. so in your viedDidLoad method you could do:
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:#selector(checkObjectMoved:) userInfo:NULL repeats:YES]; // check every 1 second
then you'd have:
- (void)checkObjectMoved:(NSTimer *)timer {
if object has NOT moved return;
[timer invalidate];
[self startGame];
}

Resources