Monday, December 9, 2013

Core Data Model Objects using Mogenerator


Download Mogenerator at http://rentzsch.github.io/mogenerator/

DownloadDownload mogenerator 1.27or install via homebrew:$ brew install mogeneratorupgrading using homebrew:$ brew update && brew upgrade mogenerator

Terminal
mogenerator --model CoreData/Model.xcdatamodeld/Model.xcdatamodel --output-dir Model/Mogenerator --template-var arc=true
XCode

1. Select your XCDataModeld
2. Editor --> Add Model Version

Projects --> Targets
Editor -->  Add Build Phases

MODELS_DIR="BeerBrowser/DataModel"
DATA_MODEL_PACKAGE="$MODELS_DIR/Beers.xcdatamodeld"
CURRENT_VERSION=`/usr/libexec/PlistBuddy "$DATA_MODEL_PACKAGE/.xccurrentversion" -c 'print _XCCurrentVersionName'`

mogenerator --template-var arc=true --model "$DATA_MODEL_PACKAGE/$CURRENT_VERSION" --output-dir "$MODELS_DIR/"


Or Simply,
/usr/local/bin/mogenerator --model "${PROJECT_DIR}/KhabarSanchar/CoreData/Model.xcdatamodeld/Model.xcdatamodel" --output-dir "${PROJECT_DIR}/Model/Mogenerator" --template-var arc=true

Sources




Saturday, October 5, 2013

Passbook App Development for iOS

Passbook is a new technology introduced in iOS6 and be quite tricky technology at first to master.
But here are few link to tutorials and helps that I hope will ease your pain.

Server API Sevices :
http://www.passdock.com/passbook-coupon/walmart-sales-coupon
http://passkit.com/

Tutorials :
http://www.raywenderlich.com/20734/beginning-passbook-part-1
http://www.raywenderlich.com/20785/beginning-passbook-in-ios-6-part-22
http://blogs.captechconsulting.com/blog/jonathan-tang/ios-6-tutorial-integrating-passbook-your-applications

Github Open source Codes :
https://github.com/passslot/passslot-ios-sdk

Design Passbook :
https://create.passkit.com/

Apple Developer Site Links:

iOS: Using Passbook
http://support.apple.com/kb/HT5483?viewlocale=en_US&locale=en_US

Passbook FAQ
https://developer.apple.com/library/ios/technotes/tn2302/_index.html

App Store Review Guidelines
23. Passbook
  • 23.1
    Passbook Passes can be used to make or receive payments, transmit offers or offer identification (such as movie tickets, airline tickets, coupons and reward offers). Other uses may result in the rejection of the App and the revocation of Passbook credentials
  • 23.2
    Passes must include valid contact information from the issuer of the pass or the App will be rejected and Passbook credentials may be revoked
  • 23.3
    Passes must be signed by the entity that will be distributing the pass under its own name, trademark, or brand or the App will be rejected and Passbook credentials may be revoked
PDFs:
Add to Passbook Badge
https://developer.apple.com/passbook/AddToPassbookBadgeGuidelines.pdf
Getting Started with Passbook on iOS 6
https://developer.apple.com/passbook/Getting_Started_with_Passbook.pdf

WWDC Videos:
https://developer.apple.com/wwdc/videos/?id=302
https://developer.apple.com/wwdc/videos/?id=303
https://developer.apple.com/videos/wwdc/2012/?id=301
https://developer.apple.com/videos/wwdc/2012/?id=309

Ebooks :
http://www.packtpub.com/passbook-applications-development-for-ios/book

Example Pass



Saturday, September 28, 2013

C++ beginers code for Objective-C Developers using XCode

Problem 1: Using CPP code show the use of If…Then…Else statement-using user input values.

Code

//
//  main.cpp
//  Hello World CPP
//
//  Created by Bishal Ghimire on 9/19/13.
//  Copyright (c) 2013 Bishal Ghimire. All rights reserved.
//

#include <iostream>

using namespace std;


/**
   IF then else function for using user input values
*/

int main(int argc, const char * argv[]) {

    int inputAge;
    std::cout << "Input You Age, !\n";
    cin >> inputAge;
   
   
    if (inputAge >= 18) {
        cout << "You can Vote ! \n";
    }
    else if (inputAge < 18) {
        cout << "You can NOT vote ! \n";
    }
    return 0;
}

Output

$ g++ main.cpp
$ ./a.out
Input You Age, !
 29
You can Vote !

Problem 2: Using functions show how you can swipe variables using call by reference.

Code

/**
    Function to swipe two variables using third temp value
 */
void swap(int *u, int *v) {
    int temp;
    temp = *u;
    *u = *v;
    *v = temp;
    return;
}

int main(int argc, const char * argv[]) {
       
    int firstValue;
    cout<<"Input First Value \n";
    cin >> firstValue;
   
    int secondValue;
    cout<<"Input Second Value \n";
    cin >> secondValue;
   
    swap(firstValue, secondValue);
   
    cout<<"First Value and Second Value after they are Swaped \n";
    cout << "1st = " << firstValue << "\n2nd = " << secondValue;
    cout<<"\n";
    return 0;
}

Output

$ g++ main.cpp
$ ./a.out
Input First Value
12
Input Second Value
34
First Value and Second Value after they are Swaped
1st = 34
2nd = 12

Problem 3: Demonstrate the use of functional overloading in CPP (C++)

 Code

/**
  functionOverLoading.cpp
*/

#include "functionOverLoading.h"

using namespace std;

#define pi 3.141

/**
 Function overloading
 */
class fxn {
public:
    void area(int);              // circle
    void area(int, int);         // rectangle
    void area(int, int, int);    // triangle
};

void fxn::area(int a) {
    cout<<"Area of Circle: "<<pi*a*a;
    cout<<"\n";
}

void fxn::area(int a, int b) {
    cout<<"Area of rectangle: "<<a*b;
    cout<<"\n";
}

void fxn::area(int a, int b, int c) {
    // cout<<"Area of triangle: "<<a*b*c;
    cout<<"\n";
}

typedef enum ChoiceType
{
    choiceCircle    = 1,
    choiceRectangle,
    choiceTriangle,
    choiceExit
} ChoiceType;


int main(int argc, const char * argv[]) {
   
    int choice;
    int radius;
    int length;
    int breath;
    int sideA, sideB, sideC;
    fxn object;
   
    cout<<"\n\t\tFunction Overloading";
    cout<<"\n 1. Area of Circle \n 2. Area of Rectangle \n 3. Area of Triangle \n 4. Exit \n ";
    cout<<"Enter your Choice:";
    cin>>choice;
   
    switch (choice) {

        case choiceCircle:
            cout<<"Enter Radious of the Circle:";
            cin>>radius;
            object.area(radius);
            break;

        case choiceRectangle:
            cout<<"Enter Sides of Rectangle:";
            cin>>length>>breath;
            object.area(length, breath);
            break;

        case choiceTriangle:
            cout<<"Enter Sides of triangle:";
            cin>>sideA>>sideB>>sideC;
            object.area(sideA, sideB, sideC);
            break;

        case choiceExit:
            exit(0);
            break;

        default:
            break;
    }
    return 0;
}

Output 

$g++ functionOverLoading.cpp –o functionOverLoading
$ ./functionOverLoading

Function Overloading
 1. Area of Circle
 2. Area of Rectangle
 3. Area of Triangle
 4. Exit
 Enter your Choice:1
Enter Radious of the Circle:10
Area of Circle: 314.1


$ ./functionOverLoading
            Function Overloading
 1. Area of Circle
 2. Area of Rectangle
 3. Area of Triangle
 4. Exit
 Enter your Choice:2
Enter Sides of Rectangle:10 12
Area of rectangle: 120