09 2011 档案

p062blocks
摘要:#import "BlocksAppDelegate.h"@implementation BlocksAppDelegate@synthesize window=_window;- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ NSArray* arr = [NSArray arrayWithObjects: @"Manny", @"Moe", @"Jack 阅读全文

posted @ 2011-09-09 11:16 upwifi 阅读(103) 评论(0) 推荐(0)

p060functionPointer
摘要:#import "FunctionPointerAppDelegate.h"@implementation FunctionPointerAppDelegate@synthesize window=_window;NSInteger sortByLastCharacter(id string1, id string2, void* context) { NSString* s1 = (NSString*) string1; NSString* s2 = (NSString*) string2; NSString* string1end = [s1 substringFrom 阅读全文

posted @ 2011-09-07 15:03 upwifi 阅读(110) 评论(0) 推荐(0)

p029static
摘要:#include <stdio.h>// just proving that static variables actually workint myfunction() { static int result = 0; // 0 means we haven't done the calculation yet if (result == 0) { result = 100; // pretend this is an expensive calculation printf("\n\nCalculating result for the first and o 阅读全文

posted @ 2011-09-06 23:01 upwifi 阅读(95) 评论(0) 推荐(0)

iOS下的DES加密
摘要:今天终于把iOS平台下的DES加密算法调通了,在这里记录一下。说一下我遇到的问题吧。 第一,关于传参,Objective-C和C,C++一样,不能把值类型数组做为参数,传给另一个方法,方法的返回值的类型也一样不可以是值类型数组。一旦这么做了,接受参数的方法只能获取数组中的首元素。 解决方法是用 NSMutableData 把值类型的数组包一层,代码如下: NSMutableData* bufkeyData = [NSMutableDatadataWithLength:2]; int* bufkey = bufkeyData.mutableByte... 阅读全文

posted @ 2011-09-05 05:33 upwifi 阅读(23085) 评论(17) 推荐(0)

p021function
摘要:#include <stdio.h>/* demonstrating how a function is declared, called, and defined *//* In the book I don't go into the fact that you can't have a function inside a functionBut you can't, and since the call to square is inside main,the definition of square must be outside main*//* 阅读全文

posted @ 2011-09-04 22:01 upwifi 阅读(110) 评论(0) 推荐(0)

NSMutableArray add int
摘要:NSNumber* rtn_key0 = [NSNumber numberWithInt:rtn_key[0]];NSMutableArray* array = [[NSMutableArray alloc] initWithCapacity:2];[array addObject:rtn_key0]; int rtn_key0 = [[array lastObject] intValue]; 阅读全文

posted @ 2011-09-03 10:44 upwifi 阅读(224) 评论(0) 推荐(0)

NSData to Byte[]
摘要:NSData to Byte[]int lengthTemp = [input_data length];Byte *byteData = (Byte*)malloc(lengthTemp);memcpy(byteData, [input_data bytes], lengthTemp);Byte[] to NSData[NSData dataWithBytes: byteData length: sizeof(byteData)]; 阅读全文

posted @ 2011-09-03 00:17 upwifi 阅读(256) 评论(0) 推荐(0)

|= 运算符
摘要:“或”赋值运算符。备注使用|=赋值运算符的表达式,例如x |= y等效于x = x | y不同的是x只计算一次。| 运算符对整型操作数执行按位逻辑“或”运算,对布尔操作数执行逻辑“或”运算。不能直接重载|=运算符,但用户定义的类型可以重载| 运算符(请参见operator)。示例// cs_operator_or_assignment.csusing System;class MainClass{ static void Main() { int a = 0x0c; a |= 0x06; Console.WriteLine("0x{0:x... 阅读全文

posted @ 2011-09-02 16:52 upwifi 阅读(520) 评论(1) 推荐(1)

BitConverter.ToUInt32
摘要:返回由字节数组中指定位置的四个字节转换来的 32 位无符号整数。// Example of the BitConverter.ToUInt32 method.using System;class BytesToUInt32Demo{ const string formatter = "{0,5}{1,17}{2,15}"; // Convert four byte array elements to a uint and display it. public static void BAToUInt32( byte[ ] bytes, int index ) { ... 阅读全文

posted @ 2011-09-02 16:02 upwifi 阅读(2880) 评论(0) 推荐(0)

NSData+Base64
摘要:#import <Foundation/Foundation.h>#import "NSData+Base64.h"int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; // insert code here... NSString *str = @"happy"; NSLog(@"原NSString: %@", str); NSData *data = [str dat 阅读全文

posted @ 2011-09-02 08:58 upwifi 阅读(4421) 评论(0) 推荐(0)

p017forloop
摘要:#include <stdio.h>int main (int argc, const char * argv[]){ /* Demonstrating a for loop Notice that the counting variable defined in the scope of the for loop is confined to the for loop Feel free to play around with the code and try out other forms of flow control */ printf("\n"); i 阅读全文

posted @ 2011-09-01 23:37 upwifi 阅读(108) 评论(0) 推荐(0)

导航