Sharing content through Twitter and facebook in ios

Almost Everyone in this world will expect that what others say about our app or our content,Being a mobile application developer how it will be if we integrate a feature to share the app content or features to the social media, would be nice right. Yes.

Here apple gives us a framework to make our work easier to spread our content around the world . Lets toss the coin to decide Twitter or Facebook gets their first place , oh ya Twitter on mark, Please read bit below , you can get the Twitter’s sample code followed by Facebook code snippet . Oh ya you got the code snippets  but i forgot saying the framework to be added to build it without compile error.

We have to add Social framework in your project then paste and modify the below codes in your class where you like spread the content of your app to globe

mySLComposerSheet = [[SLComposeViewController alloc] init];

mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

[mySLComposerSheet setInitialText:@””];

[mySLComposerSheet addImage:[UIImage imageNamed:@””]];

[self presentViewController:mySLComposerSheet animated:YES completion:nil];

For FaceBook:

mySLComposerSheet = [[SLComposeViewController alloc] init];

mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

[mySLComposerSheet setInitialText:@””];

[mySLComposerSheet addImage:[UIImage imageNamed:@””]];

[self presentViewController:mySLComposerSheet animated:YES completion:nil];

Please post your comments or share my page , if you like/love it

compose mail view controller with in application in iPhone and iPad development

iOS 3.2 and later apple provides a framework called  messageUI  framework to achieve Mail composing .

so first we need to add this framework in your project, Hope that we aware of adding a framework.
then just add these lines where you want in your app.

MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@”My Subject”];
[controller setMessageBody:@”Hello there.” isHTML:NO];
if (controller) [self presentModalViewController:controller animated:YES];
[controller release];

and for call back implement this delegate method

if (result == MFMailComposeResultSent) {
NSLog(@”It’s away!”);
[self dismissModalViewControllerAnimated:YES];


Variables & constants in Swift is a basic and fundamental concept. This tutorial is focusing on explaining let(immutable) & var(mutable) declaration. Both variable and constant two terms are self-explanatory, Constant refers to the values which never gets changed during runtime. Whereas Variable refers to the values, which can be changed during runtime.

Declaring a Constant:

let is the keyword, used to declare the constants.

let myName = “ABCD” and let age = 20

var is the keyword , used to declare the variables.

var salary= 2000;

You can change the value of this salary variable since it is declared with var keyword. whereas you can’t change the age since it is declared with let keyword.

for ex:-

salary = 3000 // works fine

age = 22 // compile error

Note: Though it is not mandatory to terminate the line with a semicolon in swift. You can use semicolon to write multiple lines in single line . ex let a = 90; var b = 100 

We will see variables & constants in detail in data type & Tuples


how to merge two UIImage and creating single Image

Sometimes we might need to merge or combine two Images and assign it to single UIImage Object ..the following code works exactly for that.

UIImage *firstImage = [UIImage imageNamed:@”a.png”];
UIImage *secondImage = [UIImage imageNamed:@”b.png”];

CGFloat firstWidth = CGGetImageWidth([firstImage CGImage]);
CGFloat firstHeight = CGGetImageHeight([firstImage CGImage]);

CGFloat secondWidth = CGGetImageWidth([secondImage CGImage]);
CGFloat secondHeight = CGGetImageHeight([secondImage CGImage]);

CGSize sizetoNewImage = CGSizeMake(firstWidth+secondWidth , firstHeight); // Here merging two images horizontally ,


[firstImage drawInRect : CGRectMake(0,0,firstWidth,firstHeight)];
[secondImage drawInRect:CGRectMake(firstWidht,0,secondWidth,secondHeight)];// Here merging two images horizontally ,

UIImage *MergedImage  = UIGraphicsGetImageFromCurrentContext();


//Thats it

Expecting FeedBack from you

How to Assign your Game data (Textures) With box2D body

When you are using Box2D in Your Game Development you might need to set graphics to box2d , so here is the step to do this.

UserData is a void pointer so you can assign your Game Data Object (eg: image object)

//set up dynamic body
b2BodyDef myBodyDef;
myBodyDef.type = b2_dynamicBody;
myBodyDef.position.Set(0, 20);
b2Body* body = world->CreateBody(&myBodyDef);

//set this Ball object in the body’s user data

body->SetUserData( this ); // here you can assign any object

//add circle fixture
b2CircleShape circleShape;
circleShape.m_p.Set(0, 0);
circleShape.m_radius = m_radius;
b2FixtureDef myFixtureDef;
myFixtureDef.shape = &circleShape;
myFixtureDef.density = 1;
Now Lets Get Back this data and draw it:

b2Body* b = m_world->GetBodyList();//get start of list
while ( b != NULL ) {

//obtain Ball pointer from user data
Ball* ball = static_cast<Ball*>( b->GetUserData() );
if ( ball != NULL ) {
ball->m_position = b->GetPosition();
ball->m_angle = b->GetAngle();
ball->m_linearVelocity = b->GetLinearVelocity();

//continue to next body
b = b->GetNext();

SOURCE; For Clear Explanation refer this Link : http://www.iforce2d.net/b2dtut/user-data

Creating Body and add it in World (BOX2D)


So we have covered the tutorial in last page about physics world and how we can create it, now its time for adding something in the world and play with it
// creating BodyDefinition

Here we create Dynamic Bodies.

b2BodyDef myBodyDef;
myBodyDef.type = b2_dynamicBody;
// create Shape Definition

b2PolygonShape polygonShape;
polygonShape.SetAsBox(1, 1); //a 2×2 rectangle

//fixture definition
b2FixtureDef myFixtureDef;
myFixtureDef.shape = &polygonShape;
myFixtureDef.density = 1;

//create dynamic bodies
m_world->CreateBody(&myBodyDef)->CreateFixture(&myFixtureDef); /// Body created and added into world

Types of Body in Box2D

Bodies have position and velocity. You can apply forces, torques, and impulses to bodies. Bodies can be
static, kinematic, or dynamic. Here are the body type definitions:
A static body does not move under simulation and behaves as if it has infinite mass. Internally, Box2D
stores zero for the mass and the inverse mass. Static bodies can be moved manually by the user. A static
body has zero velocity. Static bodies do not collide with other static or kinematic bodies.
A kinematic body moves under simulation according to its velocity. Kinematic bodies do not respond to
forces. They can be moved manually by the user, but normally a kinematic body is moved by setting its
velocity. A kinematic body behaves as if it has infinite mass, however, Box2D stores zero for the mass
and the inverse mass. Kinematic bodies do not collide with other static or kinematic bodies.
A dynamic body is fully simulated. They can be moved manually by the user, but normally they move
according to forces. A dynamic body can collide with all body types. A dynamic body always has finite,
non-zero mass. If you try to set the mass of a dynamic body to zero, it will automatically acquire a mass
of one kilogram.

Device offline when connected for device debug in Android development

When you are connecting device with your P.C for Device Debugging .eclipse may shows randomly device state is offline ,
though you unplugged and plug in again the problem will persist,
one solution for this problem is you have to restart your android device