First establish a naming convention for all the things for the method names, class names, project names, images, etc.
PROJECT NAME (Do not put space while naming a directory/folder or any classes or project name).
some key concepts for an iPhone developer to learn as a fresher
We should set the finalised title/name of the project . (Example: NetworkingView or GameCenterViewController or LeaderBoardViewController etc).
HOW TO NAME A CLASS ?
You should use Pascal Case for the folders and classes.
You should add a prefix of abbreviation of your project name to all the classes in the project.
Apple's Library reference:
How apple developers name their classes?
Example:
NSInteger
NSUserdefaults
UIView or UIButton etc.
All class names should start with a capital letter.
You should choose a meaningful class name that will be relevant to the functionality.
Example:
Suppose your project name is "SolitaireGame" and you want to create a class as
"Solitaireviewcontroller".
Your Class or Scene or Controller name should be as
"SGSolitaireViewController.h"
"SGSolitaireViewController.m"
OR
SGSolitaireViewController.h (cocos2d-x)
SGSolitaireViewController.cpp (cocos2d-x)
Note:
- You should skip this convention only if you are using any category like (UIView+Animations).
- Never create a class name like "SolitaireVC" or "SolitaireSC" or "VC" or "A"
HOW TO NAME A METHOD ?
- Use Camel Case for methods, properties & variables start with a lowercase letter i.e setFirstName:, userPassword etc.
- Your method name should be very specific to the functionality.
- Method names should be meaningful,no matter how lengthy it appears.
- It should start with a small letter.
Example:
- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
animated:(BOOL)animated
Notes:
- Don’t abbreviate names of methods,just spell them out, even if they’re long.
- Never put any method names like "abc" or "xyz" or "remove" or "add".
- Avoid ambiguity in method names that could be interpreted in more than one way.
Example:
"displayName" or "removeScene" or "removePopup".
- You should express the exact functionality with a method name.
- Methods that do the same thing in different classes should have the same name. (consistency).Never use underscores, dashes or hyphen between the words of a method
HOW TO NAME A VARIABLE ?
Naming a property or variable in objective C or C++ is same as an instance method name
It should start with a small letter.
Example:
@property (nonatomic, assign) UInt64 currentMemoryUsage;
NAMING CONSTANTS
const float VSSlotsConstants;
NAMING ENUMS
typedef enum _VSSlotsMatrixMode {
VSRadioModeMatrix = 0,
VSHighlightModeMatrix = 1,
VSListModeMatrix = 2,
VSTrackModeMatrix = 3
} VSMatrixMode;
USING SINGLETONS
Apple’s Developer Library considers the singleton one of the “Cocoa Core Competencies".
Using singletons that will create a global state in your app and a hassle free way to reuse your game states for every session.
It avoids extra memory usage and gives smooth user experience (No more object creation again and again).
Create all common and singleton objects in App Delegate and then expose them by UIResponder Category.
Example:
Creating "VSAppConfiguration.m" or "VSGameInAPPHelper.cpp"
Creating a singleton like "Music" OR "SoundHandlerClass".
FOLLOW BEST DESIGN PATTERN:
Example:
MVC (Model View Controller).
Model → Data (Brain of the application- Data & calculations)
View → User Interface (window through which your users interact with your application)
Controller → Core Logic (Bridge between the model and your Views).
Basic iOS interview Questions And Answers
Top 5 Frequently Asked iOS Interview Questions And Answers.
Top Interview Questions And Answers in Objective C
Most Important iPhone interview Questions and Answers
DIRECTORY STRUCTURE:
GLOBAL SCOPE (Constants,Global Helper Classes,Global Singletons,Global Variables,Global Resources like images,Utility Classes).
Keep the above resources in a common folder.
ISOLATED OR SEPARATE DIRECTORY (LOBBY,GAME CONROLLERS OR SCENES)
Make sure that all the resources are placed in specific folder
Example:
- Suppose you have designed a Lobby,all your resources (Model,Views,Images,sounds) used in Lobby design should be in a folder named " Lobby".
- If you have designed a Slots Machine (Game logic,UI,Sound),all the resources (Models,Views or layers or scenes or controllers) should be in particular folder like "SpinTillYouWinMachine" as follows.
- Each Plugin folder should contain all corresponding models,singletons,Views or scenes ,images,sounds .
- we should programme the plugins or Add-ons of our application as an isolated entity.
- All the business logics and popup construction should be implemented within the plugin classes,what we need to do,just call a method it will show a popup fulfilling all conditions.
- In future,if someone of our developer needs a plugin,you just have to share that folder and calling method,that's it.
USING COMMENTS AND PRAGMA MARK
Using comments or pragma marks,makes your code makes a project easy to understand and maintain further.
It puts very less stress on developers mind .
1)Use Automatic Reference Counting
Always use ARC. All new code should be written using ARC, and all
legacy code should be updated to use ARC
2)Create a property for every ivar and use self to access it Always create a @property for every data member and use “self.name”
to access it throughout your class implementation
Alway declare “atomic” or “nonatomic” attribute
Always use the “nonatomic” attribute on your properties, unless you are
writing a thread-safe class and actually need access to be atomic.
A lot more to understand in a long run.My objective of writing this article for helping you to some extent.
Suggested Reading:
Some important points About View Controller.
What Are The Main Responsibilities Of A View Controller ?
Explain The Difference Between loadView() And viewDidLoad() in iOS
How To Explain UIViewController Life Cycle in iOS ?