所以,这是一个有趣的小编程挑战.我正在写一个快速的方法来确定特定年份的所有市场假期,然后我开始阅读有关复活节的信息,并发现了确定其日期的逻辑是多么疯狂 - 春天之后的逾越节满月后的第一个星期日春分!有人知道现有的函数来计算给定年份的复活节日期吗?
当然,这可能并不那么难; 我想我会问,以防有人已经这样做了.(这似乎很有可能.)
更新:实际上,我真的在寻找耶稣受难日(复活节前的星期五)的日期......我只是觉得复活节会让我在那里.既然我在美国,我认为我正在寻找天主教复活节?但如果我错了,也许有人可以纠正我.
*通过"疯狂"我的意思,就像,参与.没有任何令人反感的......
所以,今天我很无聊,并决定搞乱C++/Obj-C插值,我找到了一种方法来创建一个非常有趣的设置.
@protocol NSCPPObj <NSObject>
-(id) init;
-(id) initWithInt:(int) value;
-(int) somethingThatReturnsAValue;
-(void) doSomething;
@end
class NSCPPObj : objc_object {
public:
static Class cls();
int iVar;
NSCPPObj();
NSCPPObj(int);
int somethingThatReturnsAValue();
void doSomething();
};
Run Code Online (Sandbox Code Playgroud)
如您所见,界面非常简单易懂.我们创建两个(几乎)相同的接口,一个用于C++对象,另一个用于Obj-C协议.
现在,我找到了一种方法来实现这一点,但是让自己好斗,这变得丑陋:
// NSCPPObj.mm
#import <objc/runtime.h>
#import <iostream>
#import "NSCPPObject.h"
Class NSCPPObj_class = nil;
__attribute__((constructor))
static void initialize()
{
NSCPPObj_class = objc_allocateClassPair([NSObject class], "NSCPPObj", 0);
class_addMethod(NSCPPObj_class->isa, @selector(alloc), imp_implementationWithBlock(^(id self) {
return class_createInstance(NSCPPObj_class, sizeof(struct NSCPPObj));
}), "@@:");
class_addMethod(NSCPPObj_class, @selector(init), imp_implementationWithBlock(^(id self) {
return self;
}), "@@:");
class_addMethod(NSCPPObj_class, @selector(initWithInt:), imp_implementationWithBlock(^(id …Run Code Online (Sandbox Code Playgroud) 文件.../FaceDeFace.app依赖于自己.
该目标可能包括自己的产品.文件.../FaceDeFace.app依赖于自己.
该目标可能包括自己的产品.
我在os Snow leopard中完成了我的项目,但现在我的操作系统版本也发生了变化,现在是10.7.3.这是安装在我的Imac机器上.这个应用程序首先在MacBook中开始,但现在我想在IMac中开发它.但是上面的错误显示了我所要做的.虽然我已经更改了所有证书,并且新更改了所有配置文件.请帮忙.谢谢我提前.
#include<stdio.h>
int main()
{
char *name = "Vikram";
printf("%s",name);
name[1]='s';
printf("%s",name);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
终端上没有打印输出,只是出现分段故障.但是当我在GDB中运行它时,我得到以下 -
Program received signal SIGSEGV, Segmentation fault.
0x0000000000400525 in main () at seg2.c:7
7 name[1]='s';
(gdb)
Run Code Online (Sandbox Code Playgroud)
这意味着程序在第7行接收SEG故障(显然我不能在常量字符数组上写入).那么为什么不执行第6行的printf()?
我需要在我的iOS应用程序中显示HTML文本.我决定使用内置方法NSAttributedString,initWithData:options:documentAttributes:error:.实际的解析工作非常好,但是,我似乎遇到了一个非常奇怪的错误,如果我附加调试器,它似乎只会表现出来.
第一次调用此方法时,在运行iOS 7.0.4的iPhone 5S上运行时间不到1秒,在iPod Touch第5代上运行约1.5秒.这个怪癖也体现在模拟器上,但由于模拟器的绝对速度,它明显不那么引人注目.
后续呼叫只需要大约10-50毫秒,这比初始呼叫要快得多.
这似乎与输入字符串的缓存无关,因为我在我的"真实"应用程序中使用多个输入字符串对其进行了测试.
但是,当我在没有调试器的情况下运行程序时,它按预期运行,大约需要10-20ms,这是我希望HTML解析所采用的.
以下是相关的代码部分:
-(void) benchmarkMe:(id)sender {
NSData *data = [testString dataUsingEncoding:NSUTF8StringEncoding];
NSTimeInterval startTime = [[NSDate date] timeIntervalSinceReferenceDate];
// So the complier doesn't keep complaining at me.
__attribute__((unused))
NSAttributedString *parsed = [[NSAttributedString alloc] initWithData:data
options:@{
NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)
}
documentAttributes:nil
error:nil];
NSTimeInterval endTime = [[NSDate date] timeIntervalSinceReferenceDate];
NSString *message = [NSString stringWithFormat:@"Took %lf seconds.", endTime - startTime];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Benchmark complete!"
message:message
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil]; …Run Code Online (Sandbox Code Playgroud) 是否可以在Python或Go中编写本机客户端应用程序,然后可以在浏览器中运行?
python google-chrome go google-chrome-extension google-nativeclient
我有一个脚本,为visual studio 2005生成一个.sln文件和几个.vcproj文件.我需要设置WorkingDirectory选项,但它在.user文件中指定.我们目前无法生成的文件.我在msdn 找到了vcproj文件定义,但似乎这个选项不能从那里设置.
如何从.sln或.vcproj文件中指定"配置属性 - >调试 - >工作目录"?
例如:
我正在尝试获取这些日期,以便我可以在我的日历上标记它,而无需手动放置未来几年的所有内容.
修改后的答案!!
$curYir = date("Y");//current year
$MLK = date('Y-m-d', strtotime("january $curYir third monday")); //marthin luthor king day
$PD = date('Y-m-d', strtotime("february $curYir third monday")); //presidents day
$Est = date('Y-m-d', easter_date($curYir))); // easter
$MDay = date('Y-m-d', strtotime("may $curYir first monday")); // memorial day
//("may $curYir last monday") will give you the last monday of may 1967
//much better to determine it by a loop
$eMDay = explode("-",$MDay);
$year = $eMDay[0]; …Run Code Online (Sandbox Code Playgroud) 在JavaScript中,有一种方法window.getSelection()可以让我获得用户所做的当前选择.
是否有相应的功能,window.setSelection()可以让我设置或清除当前的选择?
嗨,在我的项目中,我要读取一个.bin文件,其中包含传感器数据short(16 bit values).我正在使用fread函数进入缓冲区,但我觉得读入没有正确发生.我的意思是我写的东西和我读的东西之间没有一致性.你们能否说出这里出了什么问题?这不是我项目中的代码......我只想在这里验证fread和fwrite功能.
#include<stdio.h>
void main()
{
FILE *fp = NULL;
short x[10] = {1,2,3,4,5,6,5000,6,-10,11};
short result[10];
fp=fopen("c:\\temp.bin", "wb");
if(fp != NULL)
{
fwrite(x, 2 /*sizeof(short)*/, 10 /*20/2*/, fp);
rewind(fp);
fread(result, 2 /*sizeof(short)*/, 10 /*20/2*/, fp);
}
else
exit(0);
printf("\nResult");
printf("\n%d",result[0]);
printf("\n%d",result[1]);
printf("\n%d",result[2]);
printf("\n%d",result[3]);
printf("\n%d",result[4]);
printf("\n%d",result[5]);
printf("\n%d",result[6]);
printf("\n%d",result[7]);
printf("\n%d",result[8]);
printf("\n%d",result[9]);
fclose(fp)
}
Run Code Online (Sandbox Code Playgroud)
我做了fread()(HEX值)后:
temp.bin:
01 02 03 04 05 06 e1 8e 88 06 ef bf b6 0b...
Run Code Online (Sandbox Code Playgroud)
我做了fwrite()之后
stdout: …Run Code Online (Sandbox Code Playgroud) c ×2
calendar ×2
ios ×2
objective-c ×2
binaryfiles ×1
c++ ×1
clear ×1
cocoa ×1
cocoa-touch ×1
computus ×1
date ×1
datetime ×1
fread ×1
fwrite ×1
go ×1
ipad ×1
iphone ×1
javascript ×1
jquery ×1
lldb ×1
php ×1
printf ×1
python ×1
selection ×1
solution ×1
strtotime ×1
vcproj ×1
window ×1
xcode ×1