Objective-C
文章平均质量分 52
RaylnGuan
这个作者很懒,什么都没留下…
展开
-
Struct结构体定义和NSRange, NSPoint得使用
结构体类型定义:struct Date = { int year; int month; int day;};struct Date d = {2013,8,17};d.day = 6;或者typedef struct Date = { int year; int month; int day;} Da原创 2014-09-09 10:44:43 · 221 阅读 · 0 评论 -
NSArray数组的排序
main.m //// main.m// NSArraySort//// Created by Rayln Guan on 9/4/13.// Copyright (c) 2013 Rayln Guan. All rights reserved.//#import #import "Student.h"void arraySort1(){原创 2014-09-09 10:45:25 · 153 阅读 · 0 评论 -
NSNull
NSNull是为了解决字典等各种类不能放null而用的,这个对象可以放入字典中NSNull *n = [NSNull null];就这么简单原创 2014-09-09 10:45:58 · 184 阅读 · 0 评论 -
OC中的NSString的其他用法
NSLog(@"大写:%@", [str uppercaseString]);NSLog(@"小写: %@", [str lowercaseString]);NSLog(@"首字母大写, 其他字母变小写", [@"aGe", capitalizedString]);BOOL result = [@"abc" isEqualToString:@"Abc"]; //返回0, 即为fa原创 2014-09-09 10:45:09 · 215 阅读 · 0 评论 -
NSNumber的用法
//// main.m// NSNumber//// Created by rayln on 13-9-7.// Copyright (c) 2013年 rayln. All rights reserved.//#import int main(int argc, const char * argv[]){ @autorelease原创 2014-09-09 10:45:47 · 245 阅读 · 0 评论 -
对文件写入内容
void test(){ NSString *str = @"123456"; NSString *path = @"/User/Desktop/text.txt"; NSError *error; //atomically: yes是创造一个临时文件,写入到临时文件后再拷贝到目标文件。 //atomically: no是直接拷贝到目标文件原创 2014-09-09 10:44:59 · 265 阅读 · 0 评论 -
CCSprite获取点击对象
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [touches anyObject]; CGPoint p1 = [touch locationInView:nil]; //p1.y = 480-p1.y; CGPoint p3 = [原创 2014-09-09 10:47:40 · 196 阅读 · 0 评论 -
Cocos2d与chipmunk的使用
新建一个cocos2d-chipmunk项目首先AppDelegate.m中加入- (void)applicationDidFinishLaunching:(UIApplication *)application{ cpInitChipmunk();}初始化!!然后添加类TestWorld.h//// TestWorld.h// TestPiking//原创 2014-09-09 10:47:29 · 270 阅读 · 0 评论 -
NSValue的用法
//// main.m// NSValue//// Created by Rayln Guan on 9/9/13.// Copyright (c) 2013 Rayln Guan. All rights reserved.//#import void value1(){ //point是结构体。没办法直接放入array当中,这时候我们需要原创 2014-09-09 10:45:53 · 345 阅读 · 0 评论 -
NSArray用法大全
main.m//// main.m// NSArray//// Created by Rayln Guan on 9/4/13.// Copyright (c) 2013 Rayln Guan. All rights reserved.//#import #import "Student.h"int main(int argc, const c原创 2014-09-09 10:45:20 · 205 阅读 · 0 评论 -
从文件读取字符串和中文乱码解决
NSString *path = @"/User/desktop/text.txt";//可解析中文NSString *str = [NSString stringWithContentOfFile:path encoding:NSUTF8StringEncoding error:nil];//如果解析gbk中文,需要用enc原创 2014-09-09 10:44:53 · 1738 阅读 · 0 评论 -
OC中回调函数得使用(block)
main.m//// main.m// Block1//// Created by Rayln Guan on 8/30/13.// Copyright (c) 2013 Rayln Guan. All rights reserved.//#import #import "Button.h"int main(int argc, const ch原创 2014-09-09 10:44:32 · 1302 阅读 · 0 评论 -
定位程序出错位置
在.m文件中加入#ifdef _FOR_DEBUG_-(BOOL) respondsToSelector:(SEL)aSelector { printf("SELECTOR: %s\n", [NSStringFromSelector(aSelector) UTF8String]); return [super respondsToSelector:aSelector];原创 2014-09-09 10:47:24 · 209 阅读 · 0 评论 -
Copy方法
NSArray NSMutableArray copy NSArrayNSArray NSMutableArray mutableCopy NSMutableArrayNSDictionary NSMutableDictionary copy NSDictionaryNSMutableDictionary NSDictionary mutableCopy NSMutableDictionary原创 2014-09-09 10:46:09 · 225 阅读 · 0 评论 -
NSObject 和 反射的使用
//// main.m// Refect//// Created by Rayln Guan on 9/13/13.// Copyright (c) 2013 Rayln Guan. All rights reserved.//#import #import "Student.h"#import "Person.h"int main(int原创 2014-09-09 10:46:03 · 158 阅读 · 0 评论 -
NSMutableDictionary
//// main.m// NSMutableArray//// Created by rayln on 13-9-7.// Copyright (c) 2013年 rayln. All rights reserved.//#import int main(int argc, const char * argv[]){ @autor原创 2014-09-09 10:45:42 · 170 阅读 · 0 评论 -
如何把c语言字符串转成oc字符串
NSString *str = [[NSString alloc] initWithUTF8String: "123456"];[str release];或者//不用释放内存NSString *str = [NSString stringWithFormat:@"i has %i and %.2f", 19, 1.223f];initWithUTF8String原创 2014-09-09 10:44:48 · 176 阅读 · 0 评论 -
NSDictionary
字典相当于Java中的Map, 有key和value//// main.m// NSDictionary//// Created by rayln on 13-9-6.// Copyright (c) 2013年 rayln. All rights reserved.//#import int main(int argc, const char原创 2014-09-09 10:45:37 · 165 阅读 · 0 评论