Wednesday, May 18, 2011

Adding LibXML and OpenSSL to Xcode

header search path-> $(SDKROOT)/usr/include/libxml2
2) include any folder like iPhoneSimulator4.2.sdk and add this name

Thursday, May 5, 2011

make car c++

{ // car body
b2PolygonDef poly1, poly2;

// bottom half
poly1.vertexCount = 5;
poly1.vertices[4].Set(-2.2f,-0.74f);
poly1.vertices[3].Set(-2.2f,0);
poly1.vertices[2].Set(1.0f,0);
poly1.vertices[1].Set(2.2f,-0.2f);
poly1.vertices[0].Set(2.2f,-0.74f);
poly1.filter.groupIndex = -1;

poly1.density = 20.0f;
poly1.friction = 0.68f;
poly1.filter.groupIndex = -1;

// top half
poly2.vertexCount = 4;
poly2.vertices[3].Set(-1.7f,0);
poly2.vertices[2].Set(-1.3f,0.7f);
poly2.vertices[1].Set(0.5f,0.74f);
poly2.vertices[0].Set(1.0f,0);
poly2.filter.groupIndex = -1;

poly2.density = 5.0f;
poly2.friction = 0.68f;
poly2.filter.groupIndex = -1;

b2BodyDef bd;
bd.position.Set(-35.0f, 5.8f);

m_vehicle = m_world->CreateBody(&bd);
m_vehicle->CreateShape(&poly1);
m_vehicle->CreateShape(&poly2);
m_vehicle->SetMassFromShapes();
}

{ // vehicle wheels
b2CircleDef circ;
circ.density = 40.0f;
circ.radius = 0.38608f;
circ.friction = 0.8f;
circ.filter.groupIndex = -1;

b2BodyDef bd;
bd.allowSleep = false;
bd.position.Set(-33.8f, 5.0f);

m_rightWheel = m_world->CreateBody(&bd);
m_rightWheel->CreateShape(&circ);
m_rightWheel->SetMassFromShapes();

bd.position.Set(-36.2f, 5.0f);
m_leftWheel = m_world->CreateBody(&bd);
m_leftWheel->CreateShape(&circ);
m_leftWheel->SetMassFromShapes();
}

{ // join wheels to chassis
b2Vec2 anchor;
b2RevoluteJointDef jd;
jd.Initialize(m_vehicle, m_leftWheel, m_leftWheel->GetWorldCenter());
jd.collideConnected = false;
jd.enableMotor = true;
jd.maxMotorTorque = 10.0f;
jd.motorSpeed = 0.0f;
m_leftJoint = (b2RevoluteJoint*)m_world->CreateJoint(&jd);

jd.Initialize(m_vehicle, m_rightWheel, m_rightWheel->GetWorldCenter());
jd.collideConnected = false;
m_rightJoint = (b2RevoluteJoint*)m_world->CreateJoint(&jd);
}

{ // ground
b2PolygonDef box;
box.SetAsBox(11.5f, 0.5f);
box.friction = 0.62f;
#pragma mark plank height
b2BodyDef bd;
bd.position.Set(-26.0f, 4.8f);

b2Body* ground = m_world->CreateBody(&bd);
ground->CreateShape(&box);
}

make bridge C++

#pragma mark bridge
b2Body* ground = NULL;
{
b2PolygonDef sd;
sd.SetAsBox(0.2f, 0.1f);

b2BodyDef bd;
bd.position.Set(0.0f, 0.0f);
ground = m_world->CreateBody(&bd);
ground->CreateShape(&sd);
}

{
b2PolygonDef sd;
sd.SetAsBox(0.5f, 0.125f);
sd.density = 20.0f;
sd.friction = 0.2f;


b2RevoluteJointDef jd;
const int32 numPlanks = 30;

b2Body* prevBody = ground;
for (int32 i = 0; i < numPlanks; ++i)
{
b2BodyDef bd;
bd.position.Set(-14.5f + 1.0f * i, 5.0f);
b2Body* body = m_world->CreateBody(&bd);
body->CreateShape(&sd);
body->SetMassFromShapes();

b2Vec2 anchor(-15.0f + 1.0f * i, 5.0f);
jd.Initialize(prevBody, body, anchor);
m_world->CreateJoint(&jd);

prevBody = body;
}

b2Vec2 anchor(-15.0f + 1.0f * numPlanks, 5.0f);
jd.Initialize(prevBody, ground, anchor);
m_world->CreateJoint(&jd);
}

Tuesday, May 3, 2011

Basics Pointer

if a is a struct use a.b

if a is a pointer to a struct use a->b

if a is an object pointer and b is a ivar use a->b

if a is an object pointer and b is a property use a

Monday, May 2, 2011

Struct in ObjC

// in interface
struct fruit {
int a;
};
// in implementation
int main()
{
struct fruit apple;
apple.a = 1;

return 0;
}

Tuesday, April 5, 2011

UINavigation back pop View Controller

-(void)goBack:(id)sender

{

[self.navigationController popViewControllerAnimated:YES];

//[self.navigationController popToRootViewControllerAnimated:YES];

}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {





#pragma mark back buttonw

UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 55, 30);
[button setImage:[UIImage imageNamed:@"backButton.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(goBack:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem* btBack = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.leftBarButtonItem = btBack;
}

Thursday, March 24, 2011

set default zoom level in UIScrollview

- (void)viewDidLoad {

imageView= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"KK_Map-02.jpg"]];
//self.imageView = imageView;
//[tempImageView release];

[super viewDidLoad];
//aWw.delegate = self;
//[scrollView setUserInteractionEnabled:YES];
scrollView.contentSize = CGSizeMake(imageView.frame.size.width, imageView.frame.size.height);//imageView.frame.size.width*9.6, imageView.frame.size.height*0.9

//scrollView.contentOffset = CGPointMake(imageView.frame.size.width/4,
// imageView.frame.size.height/4);


//CGRect rect = CGRectMake(119, 42, 208, 166);

scrollView.maximumZoomScale = 4.0;
scrollView.minimumZoomScale = 0.33;
scrollView.clipsToBounds = YES;
scrollView.delegate = self;
scrollView.bouncesZoom=FALSE;




[scrollView addSubview:imageView];


float minimumScale = [scrollView frame].size.width / [imageView frame].size.width;
[scrollView setMinimumZoomScale:minimumScale];
[scrollView setZoomScale:minimumScale];

}

Monday, March 14, 2011

JS to Obj-c and Objc to JS

search for text which you can to test against

- (BOOL)webView:(UIWebView *)localwebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

NSURL *url = [request URL];

NSString *path = [[request URL] path];

NSString *pathTrimmed = [path lastPathComponent];

NSLog(@"sfdf %@",url);

NSLog(@"path f %@",pathTrimmed);

if ([pathTrimmed isEqualToString:@"Reset"]) {

// Display alert
UIAlertView *alertb = [[UIAlertView alloc] initWithTitle:@"You want to Reset Data??" message:@"" delegate:self cancelButtonTitle:@"No" otherButtonTitles: @"YES",nil];
alertb.tag=3;
[alertb show];

[alertb release];
return NO;
}
return YES;


}




and then based on alert call JS Function defined in html page


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {


if(buttonIndex == 1) {

//NSLog(@" its done now uplaod data");
[localwebView stringByEvaluatingJavaScriptFromString:@"confirmation()"];
}
}

Thursday, March 10, 2011

check inernet conection on iphone

NSString *connected = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com"]];

//NSLog(@" SRRINF IS %@",connected);


wait(20);

if (connected == NULL) {
NSLog(@"Not connected");

UIAlertView *alertb = [[UIAlertView alloc] initWithTitle:@"Internet is down " message:@"Check your internet connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil,nil];

[alertb show];

[alertb release];
} else {
NSLog(@"Connected - %@",connected);

Tuesday, March 8, 2011

ipad run

inseret this ti info.plost


NSMainNibFile~ipad


http:// www . devx.com/wireless/Article/44472/1763/page/2

FEEDJIT Live