小编Spo*_*ude的帖子

造成这种情况的原因是:无法从switch语句跳转到此case标签

这是一个switch语句,我收到错误:

        switch (transaction.transactionState) {

        case SKPaymentTransactionStatePurchasing:

            // show wait view here
            statusLabel.text = @"Processing...";
            break;

        case SKPaymentTransactionStatePurchased:

            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];

            // remove wait view and unlock iClooud Syncing
            statusLabel.text = @"Done!";

            NSError *error = nil;
            [SFHFKeychainUtils storeUsername:@"IAPNoob01" andPassword:@"whatever" forServiceName: kStoredData updateExisting:YES error:&error];

            // apply purchase action  - hide lock overlay and
            [oStockLock setBackgroundImage:nil forState:UIControlStateNormal];

            // do other thing to enable the features

            break;

        case SKPaymentTransactionStateRestored:

            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];

            // remove wait view here
            statusLabel.text = @"";
            break;

        case SKPaymentTransactionStateFailed:

            if …
Run Code Online (Sandbox Code Playgroud)

objective-c switch-statement ios9

48
推荐指数
1
解决办法
3万
查看次数

Xcode无法使用所选设备运行

这是尝试在XCode 4下运行时的消息(它曾经在XCode 3下工作):

没有配置的iOS设备可用.连接iOS设备或选择iOS模拟器作为目标.

我有这个应用程序的设备配置文件...我应该在哪里纠正这个?

在此输入图像描述

xcode4

42
推荐指数
3
解决办法
9万
查看次数

如何允许NSMutableDictionary接受'nil'值?

我有这样的声明:

 [custData setObject: [rs stringForColumnIndex:2]  forKey: @"email"];
Run Code Online (Sandbox Code Playgroud)

其中[rs stringForColumnIndex:2]从SQLite3的d/b中获得具有值nil.该应用程序崩溃给我错误:

NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: email)'
Run Code Online (Sandbox Code Playgroud)

有办法防止这种情况吗?(比如设置NSMutableDictionary?)

更新:这是我最终做的:

[custData setObject: ([rs stringForColumnIndex:2] != nil? [rs stringForColumnIndex:2]:@"") forKey: @"email"];
Run Code Online (Sandbox Code Playgroud)

objective-c

19
推荐指数
2
解决办法
2万
查看次数

隐式转换NSInteger错误

使用MagicalRecord,我试图用特定的clientNumber获取记录,这是一个NSInteger(定义为int16作为数据类型).

这是我的代码行,我收到错误:

ClientInfo *clientSelected = [ClientInfo MR_findFirstByAttribute:@"aClientNumber" withValue: clientNumber inContext:localContext];
Run Code Online (Sandbox Code Playgroud)

更新:这是MR_findFirstByAtytribute的定义:

MR_findFirstByAttribute:(NSString *) withValue:(id)
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

Implicit conversion of NSInteger (aka int) is disallowed with ARC
Run Code Online (Sandbox Code Playgroud)

对于我的生活,我没有看到什么是错的.ClientInfo定义为

@interface ClientInfo : NSManagedObject
Run Code Online (Sandbox Code Playgroud)

objective-c xcode4.5

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

如何格式化用户区域设置的当前日期?

我有这个代码,我正在尝试获取当前日期并在当前语言环境中格式化它.

NSDate *now = [NSDate date];  //  gets current date
NSString *sNow = [[NSString alloc] initWithFormat:@"%@",now];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"mm-dd-yyyy"];
insertCmd = [insertCmd stringByAppendingString: formatter setDateFormat: @"MM.dd.yyyy"];
Run Code Online (Sandbox Code Playgroud)

我知道最后一行是错误的,但似乎无法弄明白......"insertCmd"是我正在为FMDB命令构建的NSString.

非常感谢帮助,或指向描述它的"doc"的指针.

ios xcode4

15
推荐指数
2
解决办法
2万
查看次数

委托的__unsafe_unretained将无法构建

我从.h文件中获取此代码(代码段):

#import <UIKit/UIKit.h>
#import "ILView.h"

/**
 * Controls the orientation of the picker
 */
typedef enum {
    ILHuePickerViewOrientationHorizontal     =   0,
    ILHuePickerViewOrientationVertical       =   1
} ILHuePickerViewOrientation;

@class ILHuePickerView;

/**
 * Hue picker delegate
 */
@protocol ILHuePickerViewDelegate

/**
 * Called when the user picks a new hue
 *
 * @param hue 0..1 The hue the user picked
 * @param picker The picker used
 */
-(void)huePicked:(float)hue picker:(ILHuePickerView *)picker;

@end

/**
 * Displays a gradient allowing the user to select a hue
 */
@interface …
Run Code Online (Sandbox Code Playgroud)

objective-c ios

14
推荐指数
1
解决办法
1万
查看次数

这个MagicalRecord弃用电话的替代方法是什么?

如何在MagicalRecord中找到替换方法(已弃用)?我看过Google,SO和文档; 似乎什么都不是替代品,当然,文档中没有任何内容可以告诉您什么取代了已弃用的方法.: - {

[[NSManagedObjectContext MR_contextForCurrentThread] MR_saveErrorHandler:^(NSError *error)
Run Code Online (Sandbox Code Playgroud)

magicalrecord

12
推荐指数
1
解决办法
3081
查看次数

UITableView的"Prototype Cell"选项发生了什么变化?

我使用UITabBarController为iPad(不使用StoryBoards)创建了一个应用程序.我在视图的顶部添加了一些标签和文本字段.现在,我想在窗口中添加一个UITableView(没有控制器).当我尝试添加UITableViewCell时,Prototype Cell没有选项......

为什么?以及如何解决?

先感谢您...

objective-c ios xcode4

11
推荐指数
1
解决办法
6171
查看次数

如何让键盘移动到下一个文本字段

我有几个UITextField在一个组...我需要能够从第一个移动到最后一个,并在最后一个使它成为FirstResponder.

我认为Next键会移动焦点,而Done会使它成为FirstResponder,但显然不是.

想法?

keyboard xamarin.ios

9
推荐指数
2
解决办法
5896
查看次数

如何将字符串转换为NSData

我有一个用于创建文件的字符串.我现在需要获取该文件并将其转换为NSData对象以便作为电子邮件发送.

对不起,我不知道如何将字符串输入NSData对象!有人可以帮帮我吗?

nsdata xamarin.ios

8
推荐指数
1
解决办法
6863
查看次数