Skip to main content

iOS: starting it up


iOS and MacOS programming is based on objective-c, an object based increment of C which apple has created and maintained.

Objective-C has the many advantages over c when it comes to memory management, object defining. Although similar in spirit to c++, it is completely different syntactically as well as in implementation.

Objective-C has two files for every program: an interface file(*.h files) and an implementation file (*.m files)

The interface file has the declaration of the variables, properties and the methods.

In Objective-C, the process of calling a method is called passing messages.


iOS programming

iOS is an event based programming environment.

Views are the user interface, the glass pane of the app.

Controllers push data and images to the views and also collect user interaction data from the views. Controller is responsible for the apps behaviour. 

Model is the source of data or it is a data-store.




In the view and controller, there are different components:

1. Actions: a method/function linked to an event, such that the event will start the execution.
The return type of the method should be IBAction and the parameter should be sender.

  1. - (IBAction)restoreDefaults:(id)sender;
 
The IBAction keyword lets the storyboard identify the method to be an action method and shows in the list of methods to be linked to events. 
sender object refers to the object which triggered the event.

2. Outlets: a way to interact with the UI elements from the code.

Outlets are defined as properties in the interface file (.h), they are then used in the implementation file with any methods.

  1. @property (weak, nonatomic) IBOutlet UITextField *textField;
 
we can use the textField pointer to access the values and fields of the corresponding textfield element in the UI

3. Controls: UI elements which are used for controlling the flow, e.g: buttons, sliders, switch, etc.,

There are 3 categories of controls: Touch & drag events, editing events and value changed events.

4. Navigation controls: navigate between different views or pages within an app. (UINavigationController)

----------

(Main.storyboard) Storyboards can be used to define navigation, link between pages.

Create different views and link then using segues, which denote an event which triggers the transition from the current view to the next view.
Several types of Segues include:
1. Show: display new data in the existing view based on the layout.
2. Show detail: replaces the content in the current view controller stack. not all content may be replaced.
3. Present modally: one view controller presenting another controller modally, and waiting for an user action.
4. Popover Presentation: a view controllers is presented as a popover, linked to the current view controller.
5. Custom: implement by extending UIStoryBoardSegue
6. Unwind: reverse navigation.



Comments

Popular posts from this blog

Mundasupatti - a fun movie

I saw a movie the other day called Mundasupatti, I’m sure you’ve heard of it if you’re in Tamil Nadu. It was funny, they took a simple superstition which is around and made a fun movie out of it. It was a period film, exploring the 70’s of rural India. I was instantly reminded of swades, a great hindi film which again explores the development gap between cities and villages, it goes a bit further to compare development as seen by an Indian NASA engineer and his old house-hold nanny’s village.  While Swades was a serious film about self empowerment and braking society’s rules about casteism and encouraging education, Mundasupatti is just a funny movie about how stupid, people are.  The movie revolves around a village after which the film is named, the people in the village believe that taking a photograph causes people to get sick and die. The movie did a faithful representation of the rural India, with its proud people and crazy traditions which make no sense. People...

Don't go near cell phone towers...

AMCS/AT – Artificial Mind Control System / Artificial Telepathy Telepathy: Legilimency, Artificial Intelligence The March 23, 1991 ITV news brief "High-Tech Psychological Warfare Arrives in the Middle East" describes a US Psychological Operations (PsyOps) tactic directed against Iraqi troops in Kuwait during Operation Desert Storm. The maneuver consisted of a system in which subliminal mind-altering technology was carried on standard radio frequency broadcasts. The March 26, 1991 news brief states that among the standard military planning groups in the centre of US war planning operations at Riyadh was "an unbelievable and highly classified PsyOps program utilizing 'silent sound' techniques." The opportunity to use this method occurred when Saddam Hussein's military command-and-control system was destroyed. The Iraqi troops were then forced to use commercial FM radio stations to carry encoded commands, which were broadcast on the 100 MHz freque...

She is a very nice girl, I hate nice girls

The protagonist saves a dog from a traffic accident on his first day of high school but ends up breaking his legs. He misses the first couple of months of school and when he joins school again, the students have already settled in and have their own groups. Our protagonist once again becomes a loner. He is not complaining though, he is actually fond of it as it gives him more time to do his personal chores and improve his skills without having to help anyone out. He eventually meets the girl, Yuigahama Yui , whose dog he saved, but only the girl recognises him. Weeks later when he finds that out from someone else, he begins to suspect that Yui is nice to him because of her guilt over the accident which was caused by her dog. He confronts Yui the next day and says that she doesn’t have to feel guilty because of the accident, He did what he thought was right and that he would have been a loner even if the accident had not happened and there was nothing that she could do to ...