Resizing the imageView in objective-c

 if (img) {

                NSLog(@”iPhone Standard Resolution”);

                CGSize size=CGSizeMake(250, 108);

                UIGraphicsBeginImageContext(size);

                [img drawInRect:CGRectMake(0,0,size.width,size.height)];

                UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();

                UIGraphicsEndImageContext();

                // [backgroundImage removeFromSuperview];

                [detailImage setImage:newImage];

            }

Advertisements

Singleton class in Objective c

The use of singleton class is used to reuse the stuff which is declared in the single ton class.with the help of a singleton class the object for a class created only one and can be used through out the project.

Here is the syntax for singleton class..

the string can be accessed by

labl.text=[[SingleTonClass singleTonMethodObj]singletonClassString];

+(SingleTonClass*)singleTonMethodObj
{
static SingleTonClass *singleTonMethodObj=nil;
if (!singleTonMethodObj) {
singleTonMethodObj=[[super allocWithZone:nil]init];
}
return singleTonMethodObj;
}

+(id)allocWithZone:(NSZone *)zone
{

return [self singleTonMethodObj];
}

-(id)init
{
self= [super init];
if(self)
{
singletonClassString=@”Hii am from singleTon Class”;
}

return self;

}

 

 

 

The string declared here is the singletonClassString   can be used in all other classes by using the following syntax

[[SingleTonClass singleTonMethodObj]singletonClassString];