为什么这是对的?
#include<iostream>
using namespace std;
int main()
{
char *s="raman";
char *t="rawan";
s=t;
cout<<s;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但这是错的?
#include<iostream>
using namespace std;
int main()
{
char s[]="raman";
char t[]="rawan";
s=t;
cout<<s;
return 0;
}
Run Code Online (Sandbox Code Playgroud) 当我向上和向下滚动时,我的UITableView会在彼此的顶部添加重复的标签.因此,最后添加的标签会增加加速减速和崩溃的标签.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
UILabel *label;
label = [[UILabel alloc] initWithFrame:nameFrame];
[label setText:[name objectAtIndex:indexPath.row + indexPath.section]];
[label setFont:[UIFont fontWithName:@"Helvetica" size:18]];
[label setBackgroundColor:[UIColor clearColor]];
[cell addSubview:label];
[label release];
label = [[UILabel alloc] initWithFrame:statusFrame];
[label setText:[status objectAtIndex:indexPath.row + indexPath.section]];
[label setFont:[UIFont fontWithName:@"Helvetica" size:18]];
[label setBackgroundColor:[UIColor clearColor]];
[label setTextAlignment:(UITextAlignmentRight)];
[cell addSubview:label];
[label release];
return cell;
}
Run Code Online (Sandbox Code Playgroud) 我尝试使用以下代码,但我无法访问它.
NSDirectoryEnumerator *dirnum = [[NSFileManager defaultManager] enumeratorAtPath: @"/private/var/mobile/Library/"];
NSLog(@"DirectoryAttributes:%@",[dirnum directoryAttributes]);
Run Code Online (Sandbox Code Playgroud)
回应结果:
"DirectoryAttributes:{
NSFileCreationDate ="2008-01-01 05:38:41 GMT";
NSFileExtensionHidden = 0;
NSFileGroupOwnerAccountID = 501;
NSFileGroupOwnerAccountName = mobile;
NSFileModificationDate ="2011-07-29 11:38:10 GMT";
NSFileOwnerAccountID = 501;
NSFileOwnerAccountName = mobile;
NSFilePosixPermissions = 493;
NSFileReferenceCount = 26;
NSFileSize = 986;
NSFileSystemFileNumber = 43;
NSFileSystemNumber = 234881026;
NSFileType = NSFileTypeDirectory;
}"
帮我看一下call_history.db数据表.
谢谢.
在Xcode 4.4中,我似乎无法将编译器标志添加到单个源文件中.我试图从单个文件中删除ARC,但我无法弹出添加标志.双击或选择项目并按Enter键不起作用,也尝试选择多个并按下输入不起作用.我尝试过两个独立的项目,其中一个是我用Xcode 4.4创建的.是否有另一种手动将编译器标志添加到源文件的方法?(我没有旧版本的Xcode来查看它如何存储值[可能在pbxproj中]).
注意:MacBook Pro带Retina显示屏 - OSX 10.8
我想测试我在数据库中插入的值是否会发送回我的类的委托.
我试图模拟委托,并期望我用来填充数据库的数组.它失败是因为2 NSArray具有相同的内容但是是不同的对象.
我已经尝试在我的模型上实现isequal和hash方法,但没有成功.
这是错误日志:
'OCMockObject[NewsListViewController]: unexpected method invoked: service:<RSSService-0x4c25b90-324400011.636966: 0x4c25b90> didFinishParsingRSSWithItems:(
description102362,
description102362,
description102362,
description102362,
description102362
)
expected: service:<OCMAnyConstraint: 0x4c10f30> didFinishParsingRSSWithItems:(
description102362,
description102362,
description102362,
description102362,
description102362
)'
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点 ?
这是我的测试:
- (void) testServiceShouldNotLoadArticlesFromRSSFeedIfArticlesInDatabase {
NSArray *fakeArticles = [TestUtils createArticles:5];
[[DatabaseManager sharedManager] saveArticles:fakeArticles];
RSSService *mockService = [OCMockObject partialMockForObject:service];
id mockDelegate = [OCMockObject mockForClass:NewsListViewController.class];
[[mockDelegate expect] service:[OCMArg any] didFinishParsingRSSWithItems:fakeArticles];
mockService.delegate = mockDelegate;
[mockService loadAllArticles];
[mockService verify];
[mockDelegate verify];
}
Run Code Online (Sandbox Code Playgroud)
这是我正在测试的方法:
- (void) loadAllArticles {
NSArray *articles = [self articlesFromDatabase];
[self.delegate service:self …Run Code Online (Sandbox Code Playgroud) 我在应用程序即将退出时调用的块中有这两行
NSTimeZone* systemTimeZone = [NSTimeZone systemTimeZone];
NSTimeInterval delta = [systemTimeZone daylightSavingTimeOffset];
Run Code Online (Sandbox Code Playgroud)
我有几周的这些线.他们工作得很好.现在,应用程序在显示此错误的第二行崩溃:
- [NSCFString daylightSavingTimeOffset]:无法识别的选择器发送到实例0x1534b0
因未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [NSCFString daylightSavingTimeOffset]:无法识别的选择器发送到实例0x1534b0'**
什么?任何线索?谢谢.
由于某种原因,我有一个dispatch_async线程,它崩溃,除非我有一个NSLog()方法在它前面执行.该块运行一个从数据库中检索用户名的方法.
崩溃:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
user_web_communicator *usrWeb = [[user_web_communicator alloc]init];
NSString *author = [usrWeb getUsernameFromID:author_string];
[_author_label setText:[NSString stringWithFormat:@"Author: %@",author]];
});
Run Code Online (Sandbox Code Playgroud)
工作:
NSLog(@"Fetching author for id: %@",author_string);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
user_web_communicator *usrWeb = [[user_web_communicator alloc]init];
NSString *author = [usrWeb getUsernameFromID:author_string];
[_author_label setText:[NSString stringWithFormat:@"Author: %@",author]];
});
Run Code Online (Sandbox Code Playgroud)
错误
Run Code Online (Sandbox Code Playgroud)2013-08-19 13:56:06.149 Poll Me[4995:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '{行:AsyncImageView:0x827aa00.minX == 10 + 1*0x827b8d0.marker + -1*0x8281210.marker + 0.5*0x8281260.marker AsyncImageView:0x827aa00.minY == 27.5 + -1*0x827b910.marker + -1*0x82812a0. marker + 0.5*0x82812e0.marker + 0.5*0x82823f0.marker …
objective-c ×6
iphone ×4
ios ×2
asynchronous ×1
c ×1
c++ ×1
crash ×1
duplicates ×1
ocmock ×1
uilabel ×1
uitableview ×1
xcode ×1