UIGraphicsBeginImageContext(self.bounds.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
read moreUIGraphicsBeginImageContext(self.bounds.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
read moreNSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
//try to get list of files from new folder
NSDirectoryEnumerator *direnum = [[NSFileManager defaultManager]
enumeratorAtPath:documentsDirectory];
NSString *pname;
while (pname = [direnum nextObject])
{
if ([[pname pathExtension] isEqualToString:@"rtfd"])
{
/* don't enumerate this directory */
[direnum skipDescendents];
}
else
{
/* ...process file here... */
NSLog(pname);
}
}
read more// You need to add this method to your controller class
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}
-(IBAction)flipAction{
NSLog(@"flip");
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight
forView:self.view cache:YES];
if ([discoView superview]){
[discoView removeFromSuperview];
[termsView addSubview:flipButton];
[self.view addSubview:termsView];
}
else
{
[termsView removeFromSuperview];
[self.view addSubview:discoView];
[discoView addSubview:flipButton];
}
[UIView commitAnimations];
}
UIImage *uiImage = [UIImage imageNamed:@"myimage.png"];
CGImageRef image = uiImage.CGImage;
NSUInteger width = CGImageGetWidth(image);
NSUInteger height = CGImageGetHeight(image);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
UInt8 * rawData = malloc(height * width * 4);
int bytesPerPixel = 4;
int bytesPerRow = bytesPerPixel * width;
NSUInteger bitsPerComponent = 8;
CGContextRef context1 = CGBitmapContextCreate(
rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big
);
CGColorSpaceRelease(colorSpace ...
read more#define kAccelerationThreshold 2.2
//Somewhere in initialization
UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
accel.delegate = self;
accel.updateInterval = 1.0f/10.0f;
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
if (fabsf(acceleration.x) > kAccelerationThreshold || fabsf(acceleration.y) > kAccelerationThreshold || fabsf(acceleration.z) > kAccelerationThreshold) {
NSLog(@"Shaking!!!");
}
}
read more
if (addBracket == nil) {
BracketAddEdit *aBracket = [[BracketAddEdit alloc] initWithNibName:nil bundle:nil];
self.addBracket = aBracket;
[aBracket release];
}
[[self navigationController] pushViewController:addBracket animated:YES];
read more
/*
* IPAdress.h
*
*
*/
#define MAXADDRS 32
extern char *if_names[MAXADDRS];
extern char *ip_names[MAXADDRS];
extern char *hw_addrs[MAXADDRS];
extern unsigned long ip_addrs[MAXADDRS];
// Function prototypes
void InitAddresses();
void FreeAddresses();
void GetIPAddresses();
void GetHWAddresses();
/*
* IPAddress.c
*
*/
#include "IPAddress.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include ...
read more#!/usr/bin/python
# Takes a header file with one or more instance variables selected
# and creates properties and synthesize directives for the selected properties.
# Accepts google-style instance variables with a tailing underscore and
# creates an appropriately named property without underscore.
# Xcode script options should be as follows:
# Entire Document
# Home ...
read more