Skip to content

Moving Forward – Adding some usefull classes to your project

I have made following classes which you should add to make things really simple for you.
AppHelper —  this contains methods which are used very frequently throughout the code.
TFAlert — this is used to to create a toast like popup in iphone.
When you have added the above two classes, then you must also add following two frameworks to
the frameworks folder of your app which can be found between Resources and Products folder.
Right click->add existing frameworks and add following two frameworks
1.CoreGraphics.framework
2.QuartzCore.framework
Next is we add a preprocessor directive for our terminal logs

#ifdef _DEBUG

# define DLog(…) NSLog(__VA_ARGS__)

#else

# define DLog(…) /*..*/

#endif

 

add the above code to the pch file found in “Other Sources” section of your code.

the above code print the logs if _DEBUG is defined in our configuration.

we will define it only in debug configuration.

 

here is a video on how to do it.

http://www.screencast.com/t/hQcfyN0yKvNw

 

now the logs will be working only in debug profile and not when you work on a production profile.

after sometime i will tell you how to make a production profile or a distribution profile for installing app on devices.

add some more classes now
ImageLoader  —  A class to inherited from UIImageView which shows an image downloaded from a url without blocking the UI i.e asynchronously.
LoadingView — a loading view represented whenever a network request is being made.
XmlObject — an object used in xml parsers to store a node.
ParserSuperClass — this class is a super class for all the parsers we will write for different requests used in the project.
WNetwork — this class is used to make a network connection and then after the request is completed calls the xml parser, xml parser parses the data and gives it back to WNetwork which in turn gives it back to the UIViewController.
BaseViewController – This is the super class for all the view controllers, every view controller inherits from this class and has some already built functions and member variables which are common to every view controller .
Now that you have reached this stage, you need to add some classes to the pch file of the project so that they are included by default in every other class so that you dont need to write again and again #include for them.
To your pch  file add this

#include “AppHelper.h”

#include “BaseViewController.h”

 

Note – pch file is found in “Other Sources” section of the app.

 

The whole project till now should look somewhat like this — WordPress.zip

 

 

Advertisements

Starting a new iphone project

Before you learn iphone, memorize this picture thoroughly.
  1. Xcode->File->New Project – > Navigation-based Application (a navigation based application is the one which makes the screens slide right to left when browsing the application)
  2. Name your project as WordPress.
  3. you will see an empty list if you run this project.
Lets Explore this project now.
WordPressAppDelegate.h

#import <UIKit/UIKit.h>             // ———- import all the classes which apple has built for iphone development

@interface WordPressAppDelegate : NSObject <UIApplicationDelegate> {    —  // interface(definition) of WordPressAppDelegate class which inherits from NSObject class and conforms to UIApplicationDelegate, now conforming to a delegate means that this WordPressAppDelegate class can reply to some kind of messagess which some other  class calls on this class like : –

– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

UIWindow *window;  // a window needs to be added in every iphone object which will contain all the buttons,views,tablelist,images everything that a user will see and interact with.

UINavigationController *navigationController;  // a navigation controller will contain all the view controllers, now a whenever you are on particular screen of your application, the whole data and views and everything you are seeing on a particular screen is managed by a view controller, when you press a button anywhere on a iphone screen and it takes you to another screen,that another screen is hanled by another viewcontroller. So all the ViewControllers are ordered and managed by a big father viewcontroller which is called navigationController.

}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

@end