小编Spo*_*ude的帖子

尝试连接字符串时,无法静态分配接口类型

这是我的代码:

- (BOOL) saveSiteData  {

    //  validate all fields
    if(txtSiteID.text.length == 0 || txtSiteDesc.text.length == 0)  {
        [self Alert:@"Missing Site ID and/or Description" andData:@"Reqired fields"];
        return NO;
    }

    if(txtSTA.text.length == 0 || txtElev.text.length == 0)  {
        [self Alert:@"Missing Initial STA and/or Elevation" andData:@"Reqired fields"];        
        return NO;
    }

//    txtSiteDesc.text = txtSiteDesc.text.re  <----------  remove single quotes  TODO

    NSString selectCmd = [NSString stringWithFormat:@"%@,%@,%@", @"SELECT COUNT (*) FROM SiteData WHERE SITE_ID = '",
                          txtSiteID.text, @"'"];
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

我得到的错误信息是:无法静态分配接口类型.

为什么?以及如何解决?

objective-c

2
推荐指数
1
解决办法
2713
查看次数

将整数作为节中的项数返回时出错

我有一个iPad应用程序,使用Storyboard,Tab Bar和XCode 4.5.我的一个场景在左上象限中有一个UITableView,在右上象限中有标签和UITextBox.

当我点击第二个标签时,我将进入上述场景.这是代码:

- (void)viewDidLoad  {

    [super viewDidLoad];

    [self.collectionView registerClass:[Cell class] forCellWithReuseIdentifier:@"MY_CELL"];
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {

    return 4;
}

- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section {

    return 4;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath; {

    Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"MY_CELL" forIndexPath:indexPath];
    cell.label.text = [NSString stringWithFormat:@"%d",indexPath.item];
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

这是接口定义:

@interface ClientViewController : UIViewController <UICollectionViewDelegate, UICollectionViewDataSource> {

}
Run Code Online (Sandbox Code Playgroud)

这是错误:

*由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [UIView collectionView:numberOfItemsInSection:]:无法识别的选择器发送到实例0x7d925b0'

如您所见,我对numberOfSectionsInCollectionView使用了相同的代码.我研究过SO和Google,但没有发现任何适用的内容.

我究竟做错了什么?

objective-c ios xcode4.5 uicollectionview uicollectionviewcell

2
推荐指数
1
解决办法
2996
查看次数

如何以编程方式选择UITextField进行编辑

我有一个UITextField,我需要以编程方式选择,所以当用户点击UIDatePicker中的日期时,它将被发送到该UITextField.

这是我的代码,它没有选择UITextField; 我已经尝试了UIControlEvent的所有可能组合,但它们都不起作用.还有其他想法吗?

    //  set textField parameters
if([whichTextField isEqualToString:@"oStartTime"]) {
    oStartTime.backgroundColor = [UIColor colorWithRed:252.0/255.0 green:255.0/255.0 blue:197.0/255.0 alpha:1.0];
    [oStartTime sendActionsForControlEvents: UIControlEventTouchUpInside];

}
else if([whichTextField isEqualToString:@"oFinishTime"]) {
    oFinishTime.backgroundColor = [UIColor colorWithRed:252.0/255.0 green:255.0/255.0 blue:197.0/255.0 alpha:1.0];
    [oFinishTime sendActionsForControlEvents: UIControlEventTouchUpInside];
}
Run Code Online (Sandbox Code Playgroud)

eventtrigger uitextfield ios6 xcode4.6

2
推荐指数
1
解决办法
2255
查看次数

如何修复警告:从'NSString*'分配给'NSMutableString*'的指针类型不兼容

我有这行代码给我一个警告:

result = [result substringToIndex:[result length] - 1];
Run Code Online (Sandbox Code Playgroud)

警告是:

从'NSString*'分配给'NSMutableString*'的指针类型不兼容

我想我明白问题是什么(我使用substring返回NSString?) - 我只是不知道如何修复它.有人可以赐教吗?

objective-c nsmutablestring ios

2
推荐指数
1
解决办法
5127
查看次数

如何在构建阶段在xcode 5中运行多个bash/sh脚本?

我需要在构建阶段在XCode 5中运行两(2)个bash/sh脚本.一个创建于Crashlytics的连接,另外创建了从原来的修改一个Mainstoryboard.strings文件.

我该怎么做呢?一个接一个地运行它们?(在Google和SO中看到......没有找到解决这个问题的内容).

build-process xcode5

2
推荐指数
1
解决办法
5622
查看次数

如何修复断点文件中的冲突的Git合并?

我有一个iPad应用程序(XCode 5,iOS 7,Git源代码控制和故事板).我目前有两(2)个分支机构(App Store中为1.8.1,工作副本为2.0.0).

我在下一个版本中略微改为1.8.1,并认为XCode的源代码控制会自动更改合并到2.0.0.我想我错了.所以我尝试使用XCode的源代码控制来进行合并,这就是事情发生了变化......它进入了一个循环.所以,我杀死了XCode,并重新启动它.

现在,我正在尝试使用SourceTree进行合并.它告诉我我的工作副本中存在合并冲突,即(2.0.0).看一下2.0.0的版本,我看到了这个:

      <BreakpointProxy
     BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
     <BreakpointContent
        shouldBeEnabled = "No"
        ignoreCount = "0"
        continueAfterRunningActions = "No"
        filePath = "saori/CalendarViewController.m"
        timestampString = "404851038.443273"
<<<<<<< HEAD                              <---------------- merge conflict
        startingColumnNumber = "9223372036854775807"
        endingColumnNumber = "9223372036854775807"
        startingLineNumber = "205"
        endingLineNumber = "205"
        landmarkName = "-viewDidLoad"
=======
        startingColumnNumber = "9223372036854775807"
        endingColumnNumber = "9223372036854775807"
        startingLineNumber = "205"
        endingLineNumber = "205"
        landmarkName = "-viewDidLoad"
        landmarkType = "5">
     </BreakpointContent>
  </BreakpointProxy>
  <BreakpointProxy
     BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
     <BreakpointContent …
Run Code Online (Sandbox Code Playgroud)

git version-control xcode5

2
推荐指数
1
解决办法
3214
查看次数

如何同步两个*本地*分支

更新我在一 (1) 个存储库中有两 (2) 个本地Git分支(开发和主分支)。Develop 是最新的当前工作副本,master 不是。我如何让他们两个同步?我正在使用 SourceTree,但无论如何都看不到这样做 - 命令行是唯一的方法,还是?如果只有命令行,命令是什么?

git

2
推荐指数
1
解决办法
1662
查看次数

我需要从Bitbucket Git repo中检出单个文件夹

我有一个包含大约20个文件夹的repo,当我从SVN转换为Git时创建.是否可以从Git存储库(在Bitbucket上)签出单个文件夹?或者我必须将每个文件夹作为单独的回购?

git bitbucket

2
推荐指数
1
解决办法
7843
查看次数

在Swift中创建唯一成员集合

我没有看到任何保证像Cocoa NSSet的Swift数组/集合成员的唯一性的方法.如果这是真的,那么我想知道Swift和Cocoa还缺少什么?

如果有什么我错过了什么?

cocoa nsset swift

2
推荐指数
1
解决办法
412
查看次数

为什么NSFIleManager -fileExistsAtPath在路径正确时找不到现有文件?

我知道iOS Simulator每次运行时都会在不同的目录中找到; 考虑到这一点,我有这个代码,它给了我Core Data sqlite文件的目录:

//  find current directory for saori.sqlite
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *documentDirectory = [[fileManager URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask]firstObject];
NSString *sqliteFilePath  = [[documentDirectory URLByAppendingPathComponent:@"Application Support/SalonBook/saori.sqlite"] absoluteString];
if ([fileManager fileExistsAtPath:sqliteFilePath])
    [MagicalRecord cleanUp];  //  set stack, etc to 'nil'
else  {
    NSLog(@"\n\n-->sqlite files not found");  // log message "unable to find sqlite files
    return;
}
Run Code Online (Sandbox Code Playgroud)

这是sqliteFilePath对象的打印输出:

Printing description of sqliteFilePath:
file:///Users/rolfmarsh/Library/Developer/CoreSimulator/Devices/1EE69744-255A-45CD-88F1-63FEAD117B32/data/Containers/Data/Application/C8FF20F0-41E4-4F26-AB06-1F29936C2208/Library/Application%20Support/SalonBook/saori.sqlite
Run Code Online (Sandbox Code Playgroud)

这是Finder文件的图像: 在此输入图像描述

问题是:我转到sqliteFilePath并且确实存在saori.sqlite文件!为什么-fileExistsAtPath失败?

objective-c nsfilemanager ios-simulator ios8.1

2
推荐指数
1
解决办法
1536
查看次数