Friday 2 November 2012

The CPU has been disabled by the guest operating system" when running OS X Lion on VMWare


Find cpuid in the file "Mac OS X Lion.vmx*" and add above line after that statement like
*Mac OS X Lion.vmx  open in Notepad not in VMWare

checkpoint.vmState = ""
usb.autoConnect.device0 = ""
numvcpus = "8"
cpuid.coresPerSocket = "4"
cpuid.1.eax = "0000:0000:0000:0001:0000:0110:1010:0101"
vhv.enable = "FALSE"
mks.keyboardFilter = "allow"
vmx.buildType = "debug"
priority.grabbed = "high"
priority.ungrabbed = "normal"
bios.forceSetupOnce = "FALSE"

Thursday 28 June 2012

shake gesture coding

[UIView beginAnimations:@"RotationAnimation" context:nil];
               
                CABasicAnimation *fullRotationAnimation;
                fullRotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
                fullRotationAnimation .fromValue = DegreesToNumber(-0.9);
                fullRotationAnimation.toValue = DegreesToNumber(0.9);
                fullRotationAnimation.duration = 0.25;          // speed for the rotation. Smaller number is faster
                fullRotationAnimation.repeatCount = 1e100f;  // number of times to spin. 1 = once
                [fullRotationAnimation setFillMode:kCAFillModeBoth];
                [gestureView.layer addAnimation:fullRotationAnimation forKey:@"rotate"];
               
                [UIView commitAnimations];

Wednesday 27 June 2012

XMPP Chat Connection ChatConnection

//
//  ChatConnection.h
//  ChatModule
//
//  Created by Gaurav & Piyush on 27/06/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
// Ref: http://wiki.xmpp.org/web/Programming_XMPP_Clients
//      http://xmpp.org/xmpp-protocols/xmpp-extensions/
//      http://gauravds.blogspot.in/2012/06/nsstring-str-xmlnsjabberclient.html

#import <Foundation/Foundation.h>

#pragma mark - Chat Delegate Protocol
// a protocol
@protocol ChatDelegate <NSObject>

typedef enum ConnectionResponse{
    kConnected,
    kNotConnected
}ConnectionResponse;

Tuesday 26 June 2012

How to install Mac OS X Lion in Virtualbox [Windows]


We've already covered how to install Mac OS X Snow Leopard on a virtual machine with Virtualbox, which is great practice for installing Mac OS X on your actual computer. That guide focused on the legal method of Hackintoshing, which is to use a retail Snow Leopard installation DVD. However, there's no way to install a retail copy of Mac OS X Lion on Virtualbox, unless you already own a Mac (which is a totally unreasonable requirement). If you want to install Lion on a virtual machine in Windows, you'll have to take a different approach: distros.


get image / image url of facebook profile image using facebook ID

NSString *fbid = @"100002487000344";
NSString *imageURL = [NSString stringWithFormat:@"https://graph.facebook.com/%@/picture",fbid];

Wednesday 13 June 2012

UIImage corner with border color

CALayer * l = [imageViewRotateBg layer];
 [l setMasksToBounds:YES]; 
 [l setCornerRadius:10.0];
               
               
 // You can even add a border
 [l setBorderWidth:1.5];              
 [l setBorderColor:[[UIColor darkGrayColor] CGColor]];
imageView.image = [UIImage imageNamed:@"myImage"];

Tuesday 12 June 2012

XMPP + iphone starting

http://wiki.xmpp.org/web/Programming_XMPP_Clients  
http://xmpp.org/extensions/xep-0077.html#usecases-register 
http://xmpp.org/rfcs/rfc3920.html#streams

#import "NSStreamAdditions.h"
------------------------------------------
NSInputStream *inputStream;
    NSOutputStream *outputStream;
    CFReadStreamRef readStream ;
    CFWriteStreamRef writeStream;
------------------------------------------
- (void)viewDidLoad{
 [self connectToServerUsingStream:@"192.168.0.128"
                            portNo: 5222];
}

-(void) connectToServerUsingStream:(NSString *)urlStr
                            portNo: (uint) portNo {

Monday 11 June 2012

XMLReader : convert XML to NSDictionary

//
//  XMLReader.h
//
//

#import <Foundation/Foundation.h>

GPImage core features

GPImage => Using Category of UIImage

some util tools for UIImage

GPImageView

GPImageView : UIImageView

Used for getting the image from server (URL), cache, activity indicator, default image concept and main important point is running on main thread and using runloops
more detail visit

Friday 8 June 2012

Share Class : Email, SMS, Fb , twitter

======== Calling way  ======================= 
#import "ShareViewController.h"

ShareViewController *svc;

- (IBAction)ButtonSharePressed:(id)sender{
  
    svc = [ShareViewController new];
  
    [svc setStringMessage:@"this is a message"];
  
    [svc startShare:self];
  
}

Monday 4 June 2012

facebook post a image on wall

 NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   userImgView.image, @"picture",
                                   nil];
   
    [[AppDelegate sharedAppDelegate].facebook requestWithGraphPath:@"me/photos"
                         andParams:params
                     andHttpMethod:@"POST"
                       andDelegate:self];

Saturday 2 June 2012

CGRect with origin selection


 enum originSelection Discription

 1 2 3
 4 5 6
 7 8 9

 1 : kOriginSelectionDefault, kOriginSelectionTopLeft


 2 : kOriginSelectionTopMid

Friday 1 June 2012

nslog with pr macro preprocessor

#define pr(str,args...) NSLog(str,args);
#define pro(str)        NSLog(@"%@",str);

Monday 28 May 2012

custom navigation bar

#import <Foundation/Foundation.h>


@interface CustomNavBar : UINavigationBar {

using blocks switch to another thread and run on main thread

//   You can add hud on main thread as
//    HUD = [MBProgressHUD showHUDAddedTo:self.view.window animated:YES];

        dispatch_queue_t workerQueue = dispatch_queue_create("QueueIdentifier", NULL);
        dispatch_async(workerQueue, ^ {
           
         // do something for network or any thing which is not using UI changes
                                   
                        dispatch_sync(dispatch_get_main_queue(), ^{
                           
                          // change in UI run this code
                         // like hide HUD
                              //  [HUD removeFromSuperview];
                        });
           
        });

Sunday 27 May 2012

make zip file though cmd/ batch


------ New Stylish Way ----------------------------



make a file "zip.vbs"'



'script made by Gaurav D. Sharma
' this cmd / batch file use for make zip...
'CScript  zip.vbs "sourcepath" "targetPath" timeInSeconds
'CScript  zip.vbs  "C:\test1" "H:\mytest1\backup\fileName" 10

Tuesday 22 May 2012

How to Mask an Image

How to Mask an Image

Masking an image enables a developer to create images with irregular shapes dynamically. Masking is often used to create a user interface that is more compelling and less boring.
Take for example the following example …
maskingstoryboard.png
Creating the mask above is really simple using CoreGraphics on the iPhone. The following is a function that takes two images and uses one to mask the other.

Open Settings app in iphone using Open URL Scheme

Do you want to open settings app or any section of settings app from your iOS application? Now you can do this you can use below URLs to open different sections of Settings app.

Preference Shortcuts:
About — prefs:root=General&path=About

Thursday 17 May 2012

Z Bar SDK ( QR Code / bar code reader )

-- Note that Zbar sdk works only for presentmodel or navigation controller push view. if u want to direct open Zbar sdk it wont work.
this is demo for present model view see the red highlighted code


// write it to viewDidLoad
[self ZBarInit]; 

// write to viewWillAppear or where you want to start Zbarsdk
[self readBarCode];
-------------------------------------------------
// write these methods to .m class
- (void)ZBarInit{
    reader = [ZBarReaderViewController new];
   

thread using blocks and change in UI

double delayInSeconds = 0.2;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
       // call here your code and also change in UI
    });

base 64 encode decode

// for base 64 encode decode
static const char _base64EncodingTable[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const short _base64DecodingTable[256] = {

Set badge number which are shown at the icon top right corner

UIApplication *application = [UIApplication sharedApplication];
   
application.applicationIconBadgeNumber = 3;


Wednesday 16 May 2012

How to call a static / class methods using selectors

[MyClassName thisIsStaticMethod:@"Hello"];

Above static / class  method can be called from selector in this way ->

[NSTimer scheduledTimerWithTimeInterval:1.0f
                                             target:[MyClassName class]
                                           selector:@selector(thisIsStaticMethod:)
                                           userInfo:@"Hello"
                                            repeats:NO];


pop up animation

popup animation by gaurav sharma


- (void)popUpView:(UIView*)view{

    [self.view.window addSubview:view];
   
    [view setFrame:CGRectMake(160, 230, 1, 1)];
    
    [UIView animateWithDuration:0.5f
                          delay:0.0
                        options:UIViewAnimationOptionBeginFromCurrentState
    

Open URL iPHone

Running thread when app has been closed

- (void)applicationDidEnterBackground:(UIApplication *)application
{

Tuesday 15 May 2012

shake gesture iphone

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{
    NSLog(@"Begin");
}

Monday 14 May 2012

Remove all NSDefault users

NSUserDefaults * defs = [NSUserDefaults standardUserDefaults];
    NSDictionary * dict = [defs dictionaryRepresentation];
    for (id key in dict) {
        [defs removeObjectForKey:key];
    }
    [defs synchronize];

Thursday 10 May 2012

Push Notification


extern NSString            *deviceToken;

#define  kApplicationKey @"d702hrNiSvWSG7fGjWNMyw"
#define  kApplicationSecret @"bo8vP8vOSdO2akt_ySXolw"

UISearchBar Custom

Custom background and Keyboard appearance alert type

-(void)setSearchBarBg{
    for (UIView *subview in searchBar.subviews) {

Tuesday 8 May 2012

MyCustomTable with cell animation

ADLivelyTableView.h
-----------------------------------
#import <UIKit/UIKit.h>

extern NSTimeInterval ADLivelyDefaultDuration;
typedef NSTimeInterval (^ADLivelyTransform)(CALayer * layer, float speed);

Friday 4 May 2012

Is retina display / detect retina display or not

detect that it is retina display or not

+ (BOOL)isRetineDisplay{
    if ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] &&
        ([UIScreen mainScreen].scale == 2.0)) {
        // Retina display
        return YES;
    } else {
        // not Retine display
        return NO;
    }
}

Thread starting methods

[self performSelectorOnMainThread:@selector(makeMyProgressBarMoving) withObject:nil waitUntilDone:NO];

[NSThread detachNewThreadSelector:@selector(presentModal) toTarget:self withObject:nil];


 #import "MBProgressHUD.h"

iphone blocks tut

Thursday 3 May 2012

change UI though secondary thread iphone

- (void) viewDidLoad{
   [NSThread detachNewThreadSelector:@selector(presentModal) toTarget:self withObject:nil];
}
- (void)presentModal{
//  usleep for micro time sleep this thread  I commented this
//    usleep(200000);
 
  dispatch_queue_t workerQueue = dispatch_queue_create("QueueIdentifier", NULL);
    dispatch_sync(workerQueue, ^ {
        // change in UI through secondary thread
        [self presentModalViewController:reader animated:NO];
    });
}

Monday 30 April 2012

show HUD as activity indicator and run main thread

HUD= [MBProgressHUD showHUDAddedTo:self.view.window animated:YES];
    [self sendRequesToFBForGettingMyData];


remove where all request will complete. [HUD remove from superview];
I add it to window because that time I want interaction disable.

Thursday 26 April 2012

know which cell is selected when button clicked in cell and load that perticular cell

    UITableViewCell *clickedCell = (UITableViewCell *)[[sender superview] superview];
    NSIndexPath *indexPath = [tblMyCard indexPathForCell:clickedCell];
    int section = indexPath.section;
    int row = indexPath.row;


// code for load particular cell in table
NSArray *indexPathArray = [[NSArray alloc] initWithObjects:indexPath, nil];
[tableView reloadRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationFade];

Wednesday 25 April 2012

get UDID of iphone device

#define UDID [[UIDevice currentDevice] uniqueIdentifier]  

it returns  a NSString* object . Should define in Congif file

Friday 20 April 2012

Run Loop and lazy loading example UITableView

NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:self.urlString]];
NSURLConnection *con = [[NSURLConnection alloc]
                                    initWithRequest:req
                                    delegate:self
                                    startImmediately:NO];
 [con scheduleInRunLoop:[NSRunLoop currentRunLoop]
                           forMode:NSRunLoopCommonModes];
 [con start];
           

http://iphonedevelopment.blogspot.in/2010/05/downloading-images-for-table-without.html
8:41http://stackoverflow.com/questions/1130089/lazy-load-images-in-uitableview

Thursday 19 April 2012

UITextField set image and complete reference

UIImageView * myView = [[ UIImageView  alloc ]  initWithImage :
  [UIImage  imageNamed : @"wordpress.png" ]];
[myTextField  setLeftView :myView];
[ myTextField   setLeftViewMode: UITextFieldViewModeAlways];
[myView release ];

How to vibrate iphone though App

AudioToolbox.framework 
 
#import <AudioToolbox/AudioToolbox.h>
 
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

Image round corner

// UIImage+RoundedCorner.h
// Created by Trevor Harmon on 9/20/09.
// Free for personal or commercial use, with or without modification.
// No warranty is expressed or implied.

// Extends the UIImage class to support making rounded corners
@interface UIImage (RoundedCorner)
- (UIImage *)roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize;
- (UIImage *) normalize;
@end

Tuesday 17 April 2012

Thursday 12 April 2012

Monday 9 April 2012

Get cache image 2

- (UIImage *) getCachedImage: (NSString *) ImageURLString
{

Get Cached image

//image cache
        MyImageView *imgView = [[MyImageView alloc] initWithFrame:CGRectMake(38, 15, 28, 27)];
        [imgView setBackgroundColor:[UIColor clearColor]];
        [imgView addImageFrom:imgURL];
        [cell addSubview:imgView];

String Encoding and decoding in iOS

- (NSString *)stringByURLDecode {

Friday 30 March 2012

Make it simpler iPhone Apps using Rocket

Rocket is collection of some use ful code like FMDB, ZBarSDK, MBProgressHUD, JSON Reader etc.... use it and make app very easy

Code for see stamped logic : Reward App

// Call as  oStamps =7, uStamps =3  //  o = offer           u = user
 [self drawgrid:oStamps userStamp:uStamps dialog:dialogSTR];


Scan Bar Code / QR Code ZBarSDk in iPhone

Zxing used in Android for this purpose and in iPhone use ZBarSDK

Custom ZBarSDK
 1.  Make a UIView object (called scanView) design it as u want to customize.

GPS Location in iPhone

Make a config file and put there

// Name : Config.h >
// Add this line at import section
#import <CoreLocation/CoreLocation.h>

Config Class + GPS Location

// Name : Config.h

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>

Validate Class

// Name : Validate.h

#import <Foundation/Foundation.h>

Custom Navigation Bar

// Name : CustomNavBar.h

#import <Foundation/Foundation.h>
@interface CustomNavBar : UINavigationBar
{}

Common Functions

// Name : CommonFunctions.h
#import <Foundation/Foundation.h>

/*
 *  System Versioning Preprocessor Macros
 */

iPhone animations

[UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.2];
        [btn setFrame:CGRectMake(btn.frame.origin.x, btn.frame.origin.y+40, btn.frame.size.width, btn.frame.size.height)];
        resultText.hidden=FALSE;
        btn.tag=10;
        [UIView commitAnimations];


 //another code
 zoomedLeftLegView_female.transform = CGAffineTransformMakeScale(0.3,0.3);
      
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.5];
        zoomedLeftLegView_female.transform = CGAffineTransformMakeScale(1.0,1.0);
        [UIView commitAnimations];