Skip to content

Instantly share code, notes, and snippets.

@xiangyuan
xiangyuan / gist:3293604
Created August 8, 2012 08:55
php的一个类
<?php
namespace Dao;
/**
*
*/
class DbUtils {
private $db_server,$uname,$pwd;
@xiangyuan
xiangyuan / gist:3312806
Created August 10, 2012 09:14
presentmodel模态对话框注意
There is no need to release the view controller after the modal view controller is dismissed.
显示的时候controller会加1,消息的时候会减去1
presentModalViewController:animated: increments the retainCount by 1, and dismissModalViewControllerAnimated: decrements it by 1.
So when you allocate it (+1), present it (+1) and release it (-1), and later on it is dismissed (-1) the retainCount will be 0, the object will be deallocated, and all is fine. If you try to release it after it has been dismissed, the object has already been deallocated and it won't work.
也就是说在model视图显示出来后,controller不需要你管理,它自己会释放内存。
@xiangyuan
xiangyuan / gist:3322634
Created August 11, 2012 08:46
svn sae中mysql服务使用操用注意
如何使用
应用中使用SAE提供的MySQL服务很简单,你就像使用普通的MySQL一样即可,当然你需要开启MySQL服务,同时把URL、端口、用户名和密码等信息修改一下。
用 户 名 : accesskey(应用的accesskey)
密  码 : secretkey(应用的secretkey)
主库域名 : w.rdc.sae.sina.com.cn
从库域名 : r.rdc.sae.sina.com.cn
端  口 : 3307
数据库名 : app_appname(app_加上应用名称)
你可以将这些信息写在配置文件里,当然你也可以在程序里面使用SaeUserInfo对象实时获取。
形如使用SaeUserInfo.getAccessKey()和SaeUserInfo.getSecretKey()来获取数据库的用户名和密码。
@xiangyuan
xiangyuan / gist:3336440
Created August 13, 2012 02:01
colorWithPatternImage消耗更多内存
I was setting my viewController's view backgroundColor like this (Both view and image dimensions were 1024x768) :
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background_test"]];
将会消耗内存7.32Mb(Instrument分析得出)
而使用UIImageView添加到背景上去
UIImageView* iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
iv.userInteractionEnabled = YES;
[1]UIImageView默认的userInteractionEnabled是NO
@xiangyuan
xiangyuan / gist:3336776
Created August 13, 2012 03:39
zbar扫描的使用和iconv.dylib包的作用
/*扫描二维码部分:
导入ZBarSDK文件并引入一下框架
AVFoundation.framework
CoreMedia.framework
CoreVideo.framework
QuartzCore.framework
libiconv.dylib //这是一个字条编码转换功能使用
引入头文件#import “ZBarSDK.h” 即可使用
当找到条形码时,会执行代理方法
@xiangyuan
xiangyuan / gist:3345806
Created August 14, 2012 02:21
ios animation key path值
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/KVCAdditions.html#//apple_ref/doc/uid/TP40005299-SW6
@xiangyuan
xiangyuan / gist:3357763
Created August 15, 2012 08:54
object-c中的观察者模式
observable类操作
//
// Observable.m
// observerpattern
//
// Created by li yajie on 12-8-15.
// Copyright (c) 2012年 com.loongjoy.iPhoneFish. All rights reserved.
//
@xiangyuan
xiangyuan / ARCError.m
Created August 17, 2012 07:05 — forked from MKSG-MugunthKumar/ARCError.m
ARC error
#if ! __has_feature(objc_arc)
#error This file/class is targeted for the ARC compiler. Either turn on ARC for your project or use -fobjc-arc flag
#endif
@xiangyuan
xiangyuan / gist:3377221
Created August 17, 2012 09:04
xcode设置
设置 NSZombieEnabled YES
MallocStackLogging YES
http://www.3ogx.com/wp-content/uploads/media_1306218902447.png
@xiangyuan
xiangyuan / gist:3393186
Created August 19, 2012 07:20
Vim-PHP-IDE
注意其中的代码补全快捷键是
ctrl+x 然后再按ctrl+o就可以出现相关的进示函数操作。
https://github.com/tlhunter/Vim-PHP-IDE