iOS Device Resolutions and icon sizes

3Gs

  • Resolution: 480 x 320
  • PPI: 163 PPI
  • App Icon: 57 x 57
  • App store Icon: 512 x 512
  • Launch image: 320 x 420

4 & 4s

  • Resolution: 960 x 640
  • PPI: 326 PPI
  • App Icon: 114 x 114
  • App store Icon: 1024 x 1024
  • Launch image: 640 x 960

iPad 1 & 2

  • Resolution: 1024 x 768
  • PPI: 132 PPI
  • App Icon: 72 x 72
  • App store Icon: 512 x 512
  • Launch image: 768 x 1004 (portrait) – 1024 x 748 (landscape)

The New iPad

  • Resolution: 2048 x 1536
  • PPI: 364 PPI
  • App Icon: 144 x 144
  • App store Icon: 1024 x 1024
  • Launch image: 1536 x 2008 (portrait) – 2048 x 1496 (landscape)
Posted in iOS, technology | Leave a comment

Unix C Sockets

protocol family constants for socket function

Family Description
AF_INET IPv4 protocols
AF_INET6 IPv6 protocols
AF_LOCAL Unix domain protocols
AF_ROUTE Routing sockets
AF_KEY Key socket

type of socket for socket function

Type Description
SOCK_STREAM stream socket
SOCK_DGRAM datagram socket
SOCK_RAW raw socket

combos of family and type for the socket function

AF_INET AF_INET6 AF_LOCAL AF_ROUTE AF_KEY
SOCK_STREAM TCP TCP YES
SOCK_DGRAM UDP UDP YES
SOCK_RAW IPv4 IPv6 YES YES
Posted in C Programming, Network Programming | Leave a comment

Summary of getaddrinfo

getaddrinfo( )

actions and results based on hostname(s) and address families

Easy and readable chart thats from the networking book “Unix Network Programming” by: W. Richard Stevens.

Hostname specified by caller Address Family specified by caller Hostname string contains Result Action
!NULL hostname string. active or passive AF_UNSPEC Hostname all AAAA records returned as sockaddr_in6 () and all A records returned as sockaddr_in ()s two DNS searches. gethostbyname2 ( AF_INET6 ) with RES_USE_INET6 off gethostbyname2 ( AF_INET ) with RES_USE_INET6 off
hex string one sockaddr_in6 () inet_pton (AF_INET6)
dotted decimal one sockaddr_in () inet_pton (AF_INET)
AF_INET6 Hostname all AAAA records returned as sockaddr_in6 () ELSE all A records returned as IPv4-mapped IPv6 sockaddr_in6 (s) gethostbyname () with RES_USE_INET6
hex string one sockaddr_in6 () inet_pton (AF_INET6)
dotted decimal error: EAI _ ADDRFAMILY *
AF_INET Hostname all A records returned as sockaddr_in (s) gethostbyname () with RES_USE_INET6
hex string error: EAI _ ADDRFAMILY *
dotted decimal one sockaddr_in () inet_pton (AF_INET)
null hostname string passive AF_UNSPEC implied 0::0 , implied 0.0.0.0 one sockaddr_in6 () and one sockaddr_in () inet_pton (AF_INET6) , inet_pton (AF_INET)
AF_INET6 implied 0::0 one sockaddr_in6 () inet_pton (AF_INET6)
AF_INET implied 0.0.0.0 one sockaddr_in () inet_pton (AF_INET)
null hostname string active AF_UNSPEC implied 0::1 , implied 127.0.0.1 one sockaddr_in6 () and one sockaddr_in () inet_pton (AF_INET6) , inet_pton (AF_INET)
AF_INET6 implied 0::1 one sockaddr_in6 () inet_pton (AF_INET6)
AF_INET implied 127.0.0.1 one sockaddr_in() inet_pton(AF_INET)
Posted in C Programming, Network Programming | Leave a comment

Function for populating dynamic array with ints

int main (int argc, char* argv[] )
{
    srand(time(0));	
    int * array, numOfIntsInArray = atoi(argv[2]);
    array=(int *) Malloc( numOfIntsInArray*sizeof(int));
    getRandomNumbers( numOfIntsInArray, 50, 500, array);
...
..
...
}

void getRandomNumbers(int num, int low, int high , int * dest)
{
	int i,tmpInterval;
	for(i = 0 ; i < num; i++ )
	{
		tmpInterval = (rand () % ( high - low + 1 ) + low);
		dest[i] = tmpInterval;
	}
}
Posted in C Programming | Leave a comment

int to char array (string)

char string[MAXLINE-1];
intVal = 10;
sprintf(string, “%d”, intVal);

Posted in Uncategorized | Leave a comment

Go from view controller to root using popToRootViewControllerAnimated

Sometimes I have the need to go from a certain view controller to the root. Normally this is because you get too deep in view controllers and you don’t want the user to have to hit the back arrow over and over. To fix this you can just add an option to go back to “home” or “root” and have it implement the following code:

[self.navigationController popToRootViewControllerAnimated:YES];
Posted in iOS, objective C | Leave a comment

property list in obj c on mac. setters/getters

To start we need a prop list. So go to file->new file. Within the Resource section under Mac OS X you see a property list file. Hit next and give it the name Data.

once you have done that, click on the newly created file. It will be in your application. Right click on the screen. you will see “add row” as an option. Choose that and give it the desired property name. Once you have done that you can get/set that property with something like the following:

Here is an example of GETTER:

-(NSDictionary *)getUserSettings
{
    //get it        
    
    
    NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSString *pListFilePath = [docDir stringByAppendingPathComponent:@"data.plist"];
    NSDictionary *pListDictionary = [[NSDictionary alloc] initWithContentsOfFile:pListFilePath];

    if (!pListDictionary) {
        NSLog(@"Error YadaYada NO GOOD");
    }
    else
        NSLog(@"dict YAYAYYA %@", pListDictionary);
    
    return pListDictionary;
}

And the setter, or updater:

-(void)updateUserSettings
{
    NSString *mainBundlePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSString *dictPath = [mainBundlePath stringByAppendingPathComponent:@"userInfo.plist"];
    //here plistDict is a dictionary I created to store the key/values for my plist
    [self.plistDict writeToFile:dictPath atomically: YES];
}

and there ya go!

Posted in mac development, NSDictionary, objective C, OS X | Leave a comment

Easy inside bundle folder creation for Mac

Quick tidbit of creating folder within the bundle path

NSFileManager *fm = [NSFileManager defaultManager];
NSError *error;
NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
NSString *dataPath = [NSString stringWithFormat:@"%@/picImages", bundleRoot];
NSLog(@"dataPath is %@",dataPath);
[fm createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error];

Posted in mac development, objective C, OS X | Tagged , , | Leave a comment

TCP Local Ethernet communication – client – server Diagram

TCP Local Ethernet communication - client - server

TCP Local Ethernet communication - client - server

Posted in Network Programming | Leave a comment

Main arguments in C

The beginning of a program.

int main(int argc,char*argv[])

here we have a standard C main routine with two arguments.

argc and char*argv[]

argc
is the number of arguments supplid to the program via command line or other sources.
char*argv[]
an array of character pointers
Posted in C Programming | Leave a comment