PowenKo,iOS Tutorial 110, Create Universal Static Libraries

September 8, 2011   ·   0 Comments

Create Universal Static Libraries

Step1:

FILE\NEW Project\Framework & Library\cocoa touch static library

Step 2: Code your static library

#import <Foundation/Foundation.h>

@interface Tutorial_Lib_staticLib : NSObject{

}
- (NSArray *) fibonacci:(NSInteger) n;
- (NSInteger) factorial:(NSInteger) n;

@end

 


#import "Tutorial_Lib_staticLib.h"

@implementation Tutorial_Lib_staticLib

- (id)init
{
    self = [super init];
    if (self) {
        // Initialization code here.
    }

    return self;
}

- (NSArray *) fibonacci:(NSInteger) n {

	NSMutableArray *fib = [NSMutableArray array];

	int a = 0;
	int b = 1;
	int sum;
	int i;

	for (i=0;i < n;i++)
	{
		[fib addObject:[NSNumber numberWithInt:a]];
		sum = a + b;
		a = b;
		b = sum;
	}

	return (NSArray *) fib;
}

- (NSInteger) factorial:(NSInteger) n {
	if ( n <= 1 )
		return 1;
	else
		return n * [self factorial:( n-1 )];
}
@end

build

copy the your
xxx.a
xxx.h

to share your friends and coworkers.

sample code:

Tutorial_Lib_staticLib

 

 

 

reference:

http://www.cocoanetics.com/2010/04/universal-static-libraries/

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
iOS Tutorial9

Amazon

adsbygoogle

Recent Posts

Categories

Amazon