Go Down

Topic: Equivilant of loop() in Objective-C? (Read 1 time) previous topic - next topic

ilektron


loop() is used by the Arduino IDE to help people understand, "this will always be running."

Programming the Arduino and programming an iOS application have very little in common.  Objective-C / CocoaTouch / iOS is fully object oriented system.  While Arduino is more of a procedural system.

You won't find an equivalent of a loop() in Obj-C because it doesn't really exist.  Cocoa applications run in a constant "waiting" state, waiting for events to occur.  This is different from Arduino (or microprocessors in general) because you tend to specify what to be doing at any given time. 

Setting up a while(1) loop in an Objective-C application, to simulate Arduino's loop() would result in a very broken program.


Good answer!
http://ilektron-x.blogspot.com - Hacking and General Electronics Goodness

liudr

You are going from a dedicated processor on arduino to a multitasking processor on an iphone. Even if you can program like on arduino, your real time tasks should become much worse. From what I know with limited knowledge, a dedicated system works with other machines, ICs, sensors in real time applications but a multitasking processor works with slow human responses. When a multitasking processor is trying to run a dedicated routine, such as doing something stupid for MS word or Adobe reader, its human operator usually gets upset since the machine loses attention to keyboard pushes and mouse movements and ends up walking away for a coffee break.

Valalvax

Thanks for the help, sorry for the delay in answering, the forums did that weird thing where it appends ?token=<string> to the end of the URL and after that I'd come by and refresh the page every now and then but never took the time to troubleshoot why it wasn't loading...

Yea, I already knew I didn't want to do an infinite loop, I figured out what I needed to do, and no, loop() was not it :P

It's rough jumping from something as easy as Arduino into a mid-level complex project on something that works extremely differently

Go Up