例如,对于原始,我会这样做
if ( (x >= 6000) && (x <= 20000) )
// do something here
Run Code Online (Sandbox Code Playgroud)
并且使用NSDecimalNumber,这就是我所拥有的
if ( (([x compare:[NSNumber numberWithInt:6000]] == NSOrderedSame) ||
([x compare:[NSNumber numberWithInt:6000]] == NSOrderedDescending))
&& (([x compare:[NSNumber numberWithInt:20000]] == NSOrderedSame) ||
([x compare:[NSNumber numberWithInt:6000]] == NSOrderedAscending)) )
{
// do something here
}
Run Code Online (Sandbox Code Playgroud)
这种比较还有其他方法(更简单,更优雅)吗?如果我将值转换为原始,我使用什么原语?我不想使用CGFloat,float或double,因为我在这里处理货币.或者如果我将它们转换为上面提到的那些,有人可以验证/解释精度吗?
当用户单击textField时,我正在使用带有弹出窗口的DatePicker.但是,Picker首先显示Month,而不是首先显示日期,并且不是英国人写日期的方式.有没有办法将DatePicker中的日期格式设置为英国方式,如dd/mm/yyyy?我正在使用Achtionsheet:
-(IBAction)acsheet:(id)sender
{
actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
//CGRect pickerFrame = CGRectMake(0, 45, 0, 0);
pickerView1 = [[UIDatePicker alloc] init];
pickerView1.datePickerMode = UIDatePickerModeDate;
[actionSheet addSubview:pickerView1];
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:@selector(dismissActionSheet:)
forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];
[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
[pickerView1 addTarget:self
action:@selector(updateLabel:)
forControlEvents:UIControlEventValueChanged];
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil …Run Code Online (Sandbox Code Playgroud) 是否可以使用curl_multi记录每个进程的响应时间?这是我当前使用的代码,我只是不确定如何记录每个进程的响应时间。谢谢你的帮助!
do
{
$execReturnValue = curl_multi_exec($mh, $runningHandles);
} while ($execReturnValue == CURLM_CALL_MULTI_PERFORM);
// Loop and continue processing the request
while ($runningHandles && $execReturnValue == CURLM_OK)
{
// Wait forever for network
$numberReady = curl_multi_select($mh);
if ($numberReady != -1)
{
// Pull in any new data, or at least handle timeouts
do
{
$execReturnValue = curl_multi_exec($mh, $runningHandles);
} while ($execReturnValue == CURLM_CALL_MULTI_PERFORM);
}
}
//End Run
//Get Data and Close
foreach($ping as $cid=>$p)
{
$curlError = curl_error($c[$cid]);
if($curlError == "")
{ …Run Code Online (Sandbox Code Playgroud) 我有.db文件的问题,复制到Documents目录后获得0 KB的大小,而原始文件是137KB.我试图在SQLite Manager中打开我复制的文件.它打开,不抱怨文件损坏......它只是不包含单个表.
我复制文件的代码:
- (void) createEditableDatabase
{
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSString *writableDB = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"yc_ch.db"];
success = [fileManager fileExistsAtPath:writableDB];
if (success)
{
return;
}
NSString *defaultPath = [[NSBundle mainBundle] pathForResource:@"yc_ch" ofType:@"db"];
error = nil;
success = [fileManager copyItemAtPath:defaultPath toPath:writableDB error:&error];
if (!success)
{
NSAssert1(0, @"Failed to create writable database file:%@", [error localizedDescription]);
}
}
Run Code Online (Sandbox Code Playgroud)
检查文件是否存在,如果不是副本.检查发生在RootViewController中
- (void)viewDidLoad
{
self.subCountriesArr=[[NSMutableArray alloc]initWithCapacity:1];
NSMutableArray *subCountriesTemp=[[[NSMutableArray alloc]init]autorelease];
DBAccess *dbAccess=[[DBAccess alloc]init];
[dbAccess createEditableDatabase]; //method to copy file …Run Code Online (Sandbox Code Playgroud) 请求方法:GET请求URL:http://127.0.0.1: 8000 /注册 Django版本:1.3.1异常类型:TypeError异常值:
__init__() 有一个意外的关键字参数 'null'
异常位置:/usr/local/lib/python2.7/dist-packages/django/forms/fields.py in init,第196行Python可执行文件:/ usr/bin/python Python版本:2.7.2 Python路径:
['/ home/forent/myprograms/mysite7','/ usr/local/lib/python2.7/dad-package /oauth2-1.5.211-py2.7.egg','/ usr/local/lib/python2 .7/dist-packages','/ usr/local/lib/python2.7/did-package/python_twitter-0.8.2-py2.7.egg','/ usr/local/lib/python2.7/rem -packages/ipython-0.12-py2.7.egg','/ usr/lib/python2.7','/ usr/lib/python2.7/plat-linux2','/ usr/lib/python2.7/lib-tk','/ usr/lib/python2.7/lib-old','/ usr/lib/python2.7/lib-dynload','/ usr/local/lib/python2.7/dad -packages ','/ usr/lib/python2.7/did-package','/ usr/lib/python2.7/did-package/PIL','/ usr/lib/python2.7/did-package/glst- 0.10','/ usr/lib/python2.7 /dist-packages/gtk-2.0','/ usr/lib/pymodules/python2.7','/ usr/lib/python2.7 /dist-package /ubuntu -sso-client','/ usr/lib/python2.7/dad-packages /ubuntuone-client','/ usr/lib/python2.7/dad-package /ubuntuone-control-panel','/ usr/lib/python2.7/dist-packages/ubuntuone-couch','/ usr/lib/python2.7/did-package /ubuntuone-installer'','/ usr/lib/python2.7/record-packages /ubuntuone-存储-PR otocol']
服务器时间:2012年1月27日星期五11:11:22 -0600
#
view
from django.shortcuts import render_to_response
from registration.models import UserDetails
from forms import UserForm
from django.template import RequestContext
from django.http import HttpResponseRedirect …Run Code Online (Sandbox Code Playgroud) ios ×3
objective-c ×2
asynchronous ×1
cocoa-touch ×1
curl-multi ×1
datepicker ×1
django ×1
django-forms ×1
iphone ×1
php ×1
sqlite ×1