How to Create Single View iOS Application

How to Create Single View iOS Application

Creating single view application with hello word is easy with just a few steps. Below are described steps for starting up native application development in iOS with simple Hello word application.

  • Open Xcode from application folder or find it from finder & open it
  • Directly click create Project or select from file -> New -> Project
  • Now it will ask for to choose a template for the project. Select SingleView App & click next

Read more: How to Create and Setup a Prefix Header File for iOS

  • Next step is to set app name, bundle name & select Language. Check below screenshot.
  • In product name add your application name as you wish. It will be editable later on.
  • Select Team from a drop-down. By default, the team will be your system admin name
  • Type organization name. If you are an individual developer you can add your name or company name
  • Now the most important part is Language selection. Note that once you selected Language than it will not be editable later on. So it becomes more important to think about the future scope of the application & choose the language.
  • You can tick below check marks for Use core data & unit tests depending on required usage during the development. We will keep it unticked as it’s not required in the application right now
  • Once all fields fill up properly then click next.
  • Now it will ask to choose a path. Select location where you would like to save the project source
  • An application is now ready for the development you can start making simple controls on it & run it on a simulator for testing
  • Below the full video for creating simple single view hello word application
Share
Quick Tips to Speed up Macbook Like a Pro

Quick Tips to Speed up Macbook Like a Pro

Are you using MacBook or any other Mac system with development tools or developing apps? Then you may definitely get an issue with speed. Although usually Mac systems are configured with minimum 4 GB ram still it sometimes stucks while doing multitasking.

Consider a case while you are developing application & you will need to test the application on a simulator that will be a tidy process. You might do close unnecessary apps or sometimes have to even close the apps which you really need to keep open for making the system run smoothly.

We often consider open apps who takes more ram usage but we forget that there are some hidden activities which also consumes lots of memory & due to that system gets hanged or sometimes becomes unresponsive or stuck in the spinner loading.

 

There are few simple tricks you should try out to make your mac system runs smoother with just a couple of steps,

 

  • The first option is you have to check & understand the possible memory usage on your system. Like you are using advanced development tools like Xcode, Studio or Movie maker like tools requires more memory. So at the time its wise to upgrade your ram with at least 8 GB. That will be more than enough for run multitasking or developing tools run smoothly without any interruption.
  • If you think dashboard tools are not frequently used than remove it. To remove it go to System Preferences -> Mission Control -> Select Dashboard dropdown & make it off
  • If you are using the browser then close unnecessary tabs. Some of the sites with continues and flows may consume more memory usage & can slow down your system process
  • You can see which process is taking more memory from the Activity Monitor option. Find Activity Monitor from finder & open it. See below screenshot how it shows which process taking how much memory.

Read more: Important Tips to Test iPhone Application

  • Make sure keep your system updated with new updates provided by the apple. Keep all your software up to date. As new versions always release with the bug improvements so that might help your system to run smoothly
  • Keep removing cache files from browser & keep it clean as cache files consume lots of memory.
  • Remove unused or unnecessary files & folders from disk & keep disk clean
  • Keep the trash clean. Users often doing this mistakes by removing the files but not removing it permanently. So as it’s in the trash it will still consume your disk space so logically the file is still in your system but in a trash folder. So keep cleaning trash folder as well.
  • Don’t save any files directly on a desktop. Keep always all the files in the documents folder
  • Make sure you don’t have any apps in your application folder which are not in use at all. That takes unnecessary space on your disk.
  • Don’t use any visual effects. By default on mac visual effects are enabled. That doesn’t make any sense if you have memory issues. Its better you make it off. Go to System Preferences -> Dock & untick Magnification. Also, change Minimise effect from Genie to Scale.

There are lots of software available in the market which offers to clean mac system & remove junk files, spam from the system. But I suggest the best way is to do it manually. As these are the automated systems & sometimes at taking remove important system file & keep you in more trouble.

Share
Source Code Management Using Bitbucket

Source Code Management Using Bitbucket

What is Source Code Management & version control :

  • While working on important projects like websites, software, desktop or mobile application it becomes necessary to handle the source code at a safe place. Specifically in websites & applications requires regular updates & each time the source will be updated too. So it’s important to keep the back up of the source code.
  • Also, there are some cases where multiple persons working as a team on the same project so at that time they will work on the similar source code. So at that time its good to maintain the backup regularly so if any issue arrives at any stage we can roll back the changes or can recover from the issue by using back source.
  • Developers often keep the backup on their local systems or the generic servers where whole organization source code is maintained. Now consider a case when if any hardware issue arrives & you couldn’t be able to recover the source from the local system it can become severe issue & cost you a lot. So there would be a common solution where we should be able to manage the latest source code as well as we can manage version control.

 

What is Bitbucket & how it helps :

  • Bitbucket is basically a hosting service which allows you to sign in for free & allows to create repositories where you can take backup of your source code & perform some advanced operations as well
  • Storing a source code on bitbucket is not only free but it’s also a safe option. Consider if you are working on 40-50 projects where it becomes tidy for you to keep back of all of the projects on your local system. Now if you use Bitbucket, in that case, you can manage all of your source codes & keep your system free
  • What you can do is once you complete the update of your app or website then upload final source on bitbucket
  • Now later on when new version update arrives you can get the latest source from the bitbucket do modifications whatever requires & once you finish you can resubmit the changes back to the bitbucket server

 

Key benefits of using Bitbucket :

  • If you are an individual developer, It provides a free sign in & can upload unlimited repositories. For the organization, it provides management repositories up to 5 persons into a single team
  • Easy & quick to set up & uploads. Also can create unlimited repositories
  • It’s a safe option as it also allows you to keep your repositories private where. If you keep it private no other persons will find your repositories
  • Allows advance operations like push changes, version control

Read more: Set up UILocalNotification in iOS Swift/Objective C

If you are new to bitbucket source code management & haven’t tried it yet that you must read this carefully.

Here is step by step explanation of source code management using Bitbucket,

  • If you are new to bitbucket & haven’t signed in yet than Signup first.

https://bitbucket.org/account/signin/

  • Ok, so we have bitbucket account now next step is to make sure our system is ready for it or not. So go to Application folder & see if you have Github desktop application installed or not. If no than download it from here & install: https://desktop.github.com
  • Now if you are first time uploading git repository of your source code then create a new repository on bitbucket. For that go to Bitbucket site & click on a + button on left panel & select repository & fill up the details.
  • Now repository is created & ready to receive the source code. So the next step is keeping the copy of your source code to a desktop. Note: reason, why I prefer to keep it on a desktop, is in any other path there might be a chance to have white spaces on the file path & that may not allow working some of the commands on terminal. So always prefer to keep the copy of your source code on the desktop & also make sure it’s not compressed file. Keep it unzipped.
  • Open terminal & navigate to the desktop path

$ cd desktop

  • Now go inside your project folder

$ cd project-name

  • Initialise git command like this :

$ git init

  • Add ‘.’ (dot) Reference for the first commit on your repository

$ git add.

  • Now perform initial commit by adding some text to the readme file like this (You can change text written between single quotes) :

$ git commit -m  ‘Initial commit with contributors’

  • Now its time to add repository path origin URL

$ git remote add origin your_repository_UR

Like this: $ git remote add origin https://[email protected]/MyComp/myapp.git

  • Finally, the last option is to push your source to the bitbucket server.

$ git push origin master -f

Once above steps followed it will first ask for the password of your bitbucket account for the first time only. Later on, it will be saved to your keychain account & will be accessed directly from there.

Share
Basic iOS Application Animation Tutorial

Basic iOS Application Animation Tutorial

Using animations in iOS Application can make it more impressive. A user always loves to use something new innovative things. There are few basic animations available in both Objective C & Swift by using that we can covert a normal user experience to something special.

It’s not necessary that it will make a vast difference in the application. Some of the users even do not notice such things. But at least that will make your application stand differently than the other similar application with just a few lines of codes.

Here are some basic animation techniques available which you can utilize into your application to make it different.

View Transition animations :

This will allow page curl animation while presenting new view controller.

For Presenting :

NextView *ivc = [mainstoryboard instantiateViewControllerWithIdentifier:@”nextview”];

[UIView transitionWithView:APP_DEL.window duration:0.5 options:UIViewAnimationOptionTransitionCurlUp animations:^{

}completion:nil];

[self presentViewController:ivc animated:NO completion:nil];

 

For Dismissing :

[UIView transitionWithView:APP_DEL.window duration:0.5 options:UIViewAnimationOptionTransitionCurlDown animations:^{

}completion:nil];

[self dismissViewControllerAnimated:NO completion:nil];

 

Here are the more transition animations available which you can use in place of curl animations :

UIViewAnimationOptionTransitionFlipFromLeft    = 1 << 20,

UIViewAnimationOptionTransitionFlipFromRight   = 2 << 20,

UIViewAnimationOptionTransitionCurlUp          = 3 << 20,

UIViewAnimationOptionTransitionCurlDown        = 4 << 20,

UIViewAnimationOptionTransitionCrossDissolve   = 5 << 20,

UIViewAnimationOptionTransitionFlipFromTop     = 6 << 20,

UIViewAnimationOptionTransitionFlipFromBottom  = 7 << 20,

 

View animations with completion :

This is simple view frame animation which allows you to move view through out the animation. It will used to open view with moving animation.

view.frame = CGRectMake(0, 0, 0, 0);

[UIView animateWithDuration:0.7 animations:^{

view.frame = CGRectMake(0, 0, 375, 667);

} completion:^(BOOL finished) {

// On completion show objects on view

}];

 

This is simple view frame animation which allows you to show view with blink effect.

view.alpha = 0.0;

[UIView animateWithDuration:0.7 animations:^{

view.alpha = 1.0;

} completion:^(BOOL finished) {

// On completion show objects on view

}];

More animation methods can be used with few more features :

  • (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0);
  • (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations NS_AVAILABLE_IOS(4_0); // delay = 0.0, options = 0,
  • (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(7_0);
Share
SQLite Useful Functions for Beginners

SQLite Useful Functions for Beginners

SQLite database provides advanced functions for adding, removing, updating records into a database. It also allows performing some of the advanced levels of operations like database migration, Inner join, a grouping of tables etc.

Its normally used to store large records into the application such as managing user list, or offline records of web-based data to make sure it supports an offline load of the data in case of no internet connection.

Running with SQL functions is as faster as any other database storage options & its more convenient options too. The reason is it provides advance inserting & deleting features & clauses which allows developers to perform complex operations over a local database.

So here are some basic functions which we normally use in iOS Application for managing local database.

Save record :

– (void) doSaveMyData  {

sqlite3 *database;

[self CheckConnection];

if (sqlite3_open([dbpath UTF8String], &database) == SQLITE_OK)  {

NSString *query = [NSString stringWithFormat:@”insert into myTable values(‘%@’, ‘%@’)”, value1, value2];

const char *sqlStmt = [query UTF8String];

sqlite3_stmt *cmpSqlStmt;

sqlite3_prepare_v2(database, sqlStmt, -1, &cmpSqlStmt, NULL);

sqlite3_step(cmpSqlStmt);

sqlite3_finalize(cmpSqlStmt);

}

sqlite3_close(database);

}

For Check Database Connection (This will commonly used before any database operation)

-(void)CheckConnection {

NSArray *docpath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *docdir = [docpath objectAtIndex:0];

dbpath = [docdir stringByAppendingPathComponent:database];

BOOL success;

NSFileManager *fm = [NSFileManager defaultManager];

success = [fm fileExistsAtPath:dbpath];

if(success) {

return;   }

NSString *dbPathFromApp = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:database];

[fm copyItemAtPath:dbPathFromApp toPath:dbpath error:nil];

}

Get list of records :

-(void)doGetRecords:(NSString*)strCatID {

[self CheckConnection];

if (arrList.count > 0) {

[arrList removeAllObjects];

arrList = nil;

}

arrOutFitsList = [[NSMutableArray alloc] init];

sqlite3 *database;

if (sqlite3_open([dbpath UTF8String], &database)==SQLITE_OK) {

NSString *query = [NSString stringWithFormat:@”select * from myTable where cat_id = ‘%@””,strCatID];

const char *sqlStmt = [query UTF8String];

sqlite3_stmt *cmpsqlstmt;

if (sqlite3_prepare_v2(database, sqlStmt, -1, &cmpsqlstmt, NULL) == SQLITE_OK) {

while (sqlite3_step(cmpsqlstmt) == SQLITE_ROW) {

DetailDict *obj = [DetailDict new];

obj.id = [NSString stringWithFormat:@”%d”,(int)sqlite3_column_int(cmpsqlstmt, 0)];

obj.Tag = [NSString stringWithUTF8String:(char*)sqlite3_column_text(cmpsqlstmt, 1)];

[arrOutFitsList addObject:obj];

}

sqlite3_finalize(cmpsqlstmt);

}

sqlite3_close(database);

}

Update record :

-(void)doUpdaterecord {

[self CheckConnection];

sqlite3 *database;

if (sqlite3_open([dbpath UTF8String], &database)==SQLITE_OK) {

NSString *query = [NSString stringWithFormat:@”update myTable set cat_id=’%@’, Tag=’%@'”, self.objDetailsDict.cat_id, self.objDetailsDict.Tag];

const char *sqlStmt = [query UTF8String];

sqlite3_stmt *cmpSqlStmt;

sqlite3_prepare_v2(database, sqlStmt, -1, &cmpSqlStmt, NULL);

sqlite3_step(cmpSqlStmt);

sqlite3_finalize(cmpSqlStmt);

}

sqlite3_close(database);

}

Remove Record :

-(void)doRemoveRecord:(NSString*)stID {

[self CheckConnection];

sqlite3 *database;

if (sqlite3_open([dbpath UTF8String], &database)==SQLITE_OK) {

NSString *query = [NSString stringWithFormat:@”DELETE FROM myTable WHERE id=’%@'”,stID];

const char *sqlStmt = [query UTF8String];

sqlite3_stmt *cmpSqlStmt;

sqlite3_prepare_v2(database, sqlStmt, -1, &cmpSqlStmt, NULL);

sqlite3_step(cmpSqlStmt);

sqlite3_finalize(cmpSqlStmt);

}

sqlite3_close(database);

}

Count Number of Records :

-(int)doCountToalRecords:(NSString *)ID {

[self CheckConnection];

int totalIS = 0;

sqlite3 *database;

if (sqlite3_open([dbpath UTF8String], &database)==SQLITE_OK) {

NSString *query = [NSString stringWithFormat:@”SELECT Count(*) FROM myTable where cat_id = ‘%@'”,ID];

const char *sqlStmt = [query UTF8String];

sqlite3_stmt *cmpsqlstmt;

if (sqlite3_prepare_v2(database, sqlStmt, -1, &cmpsqlstmt, NULL) == SQLITE_OK) {

while (sqlite3_step(cmpsqlstmt) == SQLITE_ROW) {

totalIS = sqlite3_column_int(cmpsqlstmt, 0);

}

}

sqlite3_finalize(cmpsqlstmt);

sqlite3_close(database);

}

return totalIS;

}

Add new field to existing table :

-(void)doAddNewFieldToTable {

sqlite3 *database;

if (sqlite3_open([dbpath UTF8String], &database)==SQLITE_OK) {

NSString *query = @”ALTER TABLE myTable ADD COLUMN newField Varchar”;

const char *sqlStmt = [query UTF8String];

sqlite3_stmt *cmpsqlstmt;

if (sqlite3_prepare_v2(database, sqlStmt, -1, &cmpsqlstmt, NULL) == SQLITE_OK) {

while (sqlite3_step(cmpsqlstmt) == SQLITE_DONE) {

NSLog(@”Success”);

}

}

sqlite3_finalize(cmpsqlstmt);

sqlite3_close(database);

}

}

So in this blog we have covered up all basic operations performed in sqlite database such as inserting, fetching, updating, removing records & also for counting number of records, adding new field to existing table while working with Objective C in iOS Application.

Share
Convert Your Project to Latest Swift Version

Convert Your Project to Latest Swift Version

Whenever new Xcode version release or any new OS releases apps developed with the swift language are needed to convert to the new swift version. There might be syntax changes or any bugs solving or something done in the swift language which requires apps to be updated with latest stable version.

Now, in this case, developers often try to make compatibility by manually running app & finding the bugs. Now, this process consumes more time & sometimes it takes too long to debug & find the exact solution. Overall it becomes tidy process & not exactly what Apple prefers.

So here are the proper steps to perform the process:

First of all, open your project into latest Xcode version & make sure don’t run it the first time.

Go to Edit -> Convert -> To current swift syntax

This will open hierarchy of files. Make sure there will be all files selected with a check mark which you wants to convert to latest swift syntax. If any files not selected or you don’t want that to a concert than manually uncheck it. Then clicking on done will do the rest of the work.

Note :

In new swift version, latest swift conversion process works perfectly & don’t require actually to manually resolve any errors. But still, there could be the chance of any errors skipped by the compiler or unable to detect the difference will keep remain & can show an error so that requires handling manually.

Share
Share