- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 Storyboard中有两个 UITextField
,用于接收用户输入的数字,minPrice 和 maxPrice。当我在模拟器中点击提交时,应用程序崩溃并且我收到以下错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[3]'
*** First throw call stack:
(
0 CoreFoundation 0x02a881e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x026468e5 objc_exception_throw + 44
2 CoreFoundation 0x02a4e376 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 390
3 CoreFoundation 0x02a7bc29 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 73
4 Parse+Storyboard 0x0000b5b5 -[CriteriaViewController submitButton:] + 757
5 libobjc.A.dylib 0x02658880 -[NSObject performSelector:withObject:withObject:] + 77
6 UIKit 0x013083b9 -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x01308345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x01409bd1 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x01409fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x01409243 -[UIControl touchesEnded:withEvent:] + 641
11 UIKit 0x01347ddd -[UIWindow _sendTouchesForEvent:] + 852
12 UIKit 0x013489d1 -[UIWindow sendEvent:] + 1117
13 UIKit 0x0131a5f2 -[UIApplication sendEvent:] + 242
14 UIKit 0x01304353 _UIApplicationHandleEventQueue + 11455
15 CoreFoundation 0x02a1177f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16 CoreFoundation 0x02a1110b __CFRunLoopDoSources0 + 235
17 CoreFoundation 0x02a2e1ae __CFRunLoopRun + 910
18 CoreFoundation 0x02a2d9d3 CFRunLoopRunSpecific + 467
19 CoreFoundation 0x02a2d7eb CFRunLoopRunInMode + 123
20 GraphicsServices 0x02ce55ee GSEventRunModal + 192
21 GraphicsServices 0x02ce542b GSEventRun + 104
22 UIKit 0x01306f9b UIApplicationMain + 1225
23 Parse+Storyboard 0x000020ed main + 141
24 libdyld.dylib 0x038e2701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
CriteriaViewController.h:
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import "SearchViewController.h"
@interface CriteriaViewController : UIViewController{
IBOutlet UISegmentedControl *Segment;
}
//@property (nonatomic) IBOutlet UITextField *itemSearch;
@property (weak, nonatomic) IBOutlet UITextField *minPrice;
@property (weak, nonatomic) IBOutlet UITextField *maxPrice;
@property (nonatomic, copy) NSNumber *chosenCategory;
@property (weak, nonatomic) NSString *itemCondition;
@property (weak, nonatomic) NSString *itemLocation;
@property (weak, nonatomic) NSString *itemSearch;
@end
CriteriaViewController.m:
#import "CriteriaViewController.h"
@interface CriteriaViewController ()
@property (weak, nonatomic) IBOutlet UISegmentedControl *itemConditionSegment;
@property (weak, nonatomic) IBOutlet UISegmentedControl *itemLocationSegment;
@end
@implementation CriteriaViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Condition UISegment
UISegmentedControl *conditionSegmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Only New", @"Any", nil]];
conditionSegmentedControl.frame = CGRectMake(87, 190, 157, 30);
conditionSegmentedControl.selectedSegmentIndex = 0;
conditionSegmentedControl.tintColor = [UIColor blackColor];
[conditionSegmentedControl addTarget:self action:@selector(ConditionSegmentControlAction:) forControlEvents: UIControlEventValueChanged];
[self.view addSubview:conditionSegmentedControl];
// Location UISegment
UISegmentedControl *locationSegmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Fast Shipping", @"Large Selection", nil]];
locationSegmentedControl.frame = CGRectMake(67, 275, 200, 30);
locationSegmentedControl.selectedSegmentIndex = 0;
locationSegmentedControl.tintColor = [UIColor blackColor];
[locationSegmentedControl addTarget:self action:@selector(LocationSegmentControlAction:) forControlEvents: UIControlEventValueChanged];
[self.view addSubview:locationSegmentedControl];
// Submit button
UIButton *submitButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; // Create Round Rect Type button.
submitButton.frame = CGRectMake(100, 100, 100, 100); // define position and width and height for the button.
[submitButton setTitle:@"Submit" forState:UIControlStateNormal];
[submitButton addTarget:self action:@selector(submitButton:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:submitButton];
}
- (void)ConditionSegmentControlAction:(UISegmentedControl *)segment
{
if(segment.selectedSegmentIndex == 0)
{
// set condition to new
self.itemCondition = @"new";
}
else if (segment.selectedSegmentIndex == 1)
{
// set condition to all
self.itemCondition = @"all";
}
}
- (void)LocationSegmentControlAction:(UISegmentedControl *)segment
{
if(segment.selectedSegmentIndex == 0)
{
// set location to us
self.itemLocation = @"US";
}
else if (segment.selectedSegmentIndex == 1)
{
// set clocation to worldwide
self.itemLocation = @"Worldwide";
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//add all the info to users respective new category object
- (IBAction)submitButton:(id)sender
{
if (self.minPrice.text.length > 0 && self.maxPrice.text.length > 0) {
[PFCloud callFunctionInBackground:@"userCategorySave"
withParameters:@{@"categoryId": self.chosenCategory,
@"minPrice": self.minPrice,
@"maxPrice": self.maxPrice,
@"itemCondition": self.itemCondition,
@"itemLocation": self.itemLocation
}
block:^(NSString *result, NSError *error) {
if (!error) {
NSLog(@"Criteria successfully saved.");
[self performSegueWithIdentifier:@"SearchCategoryChooserToMatchCenterSegue" sender:self];
}
}];
}
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
[PFCloud callFunctionInBackground:@"addToMatchCenter"
withParameters:@{
// @"searchTerm": self.itemSearch,
@"categoryId": self.chosenCategory,
// @"minPrice": self.minPrice,
// @"maxPrice": self.maxPrice,
// @"itemCondition": self.itemCondition,
// @"itemLocation": self.itemLocation,
}
block:^(NSString *result, NSError *error) {
if (!error) {
NSLog(@"'%@'", result);
}
}];
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
@end
云代码:
Parse.Cloud.define("userCategorySave", function(request, response) {
var userCategory = Parse.Object.extend("userCategory");
var newUserCategory = new userCategory();
newUserCategory.set("categoryId", request.params.categoryId);
newUserCategory.set("minPrice", request.params.minPrice);
newUserCategory.set("maxPrice", request.params.maxPrice);
newUserCategory.set("itemCondition", request.params.itemCondition);
newUserCategory.set("itemLocation", request.params.itemLocation);
newUserCategory.set("parent", Parse.User.current());
newUserCategory.save({
success: function (){
console.log ('userCategory successfully created!');
response.success('userCategory successfully created!');
},
error: function (){
console.log('error!!!');
response.error('Request failed');
}
});
});
我认为问题是 UITextFields 以我的云代码不喜欢的格式发送数字。除了这个错误之外,我想设置它以便在此字段中输入值时只允许使用数字。
我如何以编程方式创建这两个字段,以便以与云代码兼容的格式发送数据,并且只允许数字?
最佳答案
你的一个属性——它看起来像 itemCondition
——显然是 nil。这可能是因为你的属性很弱,所以在你有机会查看它之前变量被取消了,或者可能是因为你选择的段不是你正在测试的值之一,因此变量永远不会设置。我不明白为什么这些字符串属性很弱,我强烈怀疑它们不应该如此。
关于ios - 'NSInvalidArgumentException',原因 : '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[3]' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23897751/
目录 count作用 测试 count(*) count(1) count(col) count(id):统计id count(inde
目录 1.初识COUNT 2.COUNT(字段)、COUNT(常量)和COUNT(*)之间的区别 3.COUNT(*)的优化 MyIS
以下 SQL Server 2008 语句之间有什么区别? SELECT COUNT(*) FROM dbo.Regular_Report SELECT COUNT(0) FROM dbo.Regul
如果字符串(短语)中只有元音,它(对我而言)说True;否则说 False。我不明白为什么它总是返回 False,因为 (x >= x) 总是返回 True。我感谢任何人检查此查询的解决方案。 (st
1.概述 在这个文章之前,我一直用count(1) 查询所有数据,以前我们都是说 count(*) 是最慢的。但是这个博客恰恰相反。 对于 count(主键 id) 来说,InnoDB 引擎会遍历整张
这个问题已经有答案了: Count(*) vs Count(1) - SQL Server (13 个回答) 已关闭 8 年前。 我经常发现这三种变体: SELECT COUNT(*) FROM Fo
为什么三个查询的成本相同?我想至少应该有一个更快。否则,只使用关键字 COUNT() 而不是 COUNT(parameter) 就可以了。 例如,以下是不依赖于参数的 COUNT() 示例实现: wh
我有一个“产品”表和一个“评论”表。 我想编写一个查询来返回每个产品的评论的 COUNT 和 AVG。 并且如果没有评论,我希望它为 COUNT 和 AVG 返回 0/null。 产品表 +-----
我会保持简短和亲切,因为我确信我缺少的是一些简单的东西。我正在尝试获取一个 NSMutableArray 的计数,它可以包含可变数量的对象(id 号)。数组是从 JSon 数据创建的,数组本身是完美创
我想知道查询计数的计数。 查询是 sourcetype="cargo_dc_shipping_log" OR sourcetype="cargo_dc_deliver_log" | stats cou
任何人都知道我如何在 SQL 炼金术中进行计数 COUN(IF(table_row = 1 AND table_row2 =2),1,0) 我做了这样的东西, func.COUNT(func.IF((
我有一个有四列的表(销售); id, user_id, product_id, and date_added. 我需要统计某个用户已售出的具有特定 id 的产品数量,并获取该用户当月售出的产品总数。
我是来问这个问题的实现的 MYSQL count of count? 我的问题是将我从一个表中提取结果的结果联系起来,使用它们来查询同一数据库的另一个表 (抱歉,我不是强大的 xySQL)。 我有一个
这是我的查询 SELECT COUNT(*) as total, toys, date FROM T1 WHERE (date >= '2012-06-26'AND date '0') UNION
我有 2 个表:成员,订单。 Members: MemberID, DateCreated Orders: OrderID, DateCreated, MemberID 我想找出给定月份中新成员的数
我最近在一次采访中被问到这个问题。我在 mySQL 中尝试了这个,并得到了相同的结果(最终结果)。All 给出了该特定表中的行数。谁能解释它们之间的主要区别。 最佳答案 没什么,除非您在表格中指定字段
我有一个包含 2157 条记录的表,假设有 3 列(A、B、C),我知道在 A 列中有 2154 个不同的值。 使用连接到 BigQuery 的 Tableau Desktop(及其自身的功能),我得
我试图查看当天的车辆销量,并创建另外两个列来告诉我过去 10 天的销量和过去 20 天的销量。同一天和同一辆车可能有多个销售。我的目标是获取不同的车辆和日期并查看他们的销售数量。 N 天计数应与该行中
我有一个非常简单的问题。我想知道某个数据库行是否存在。 我通常使用: SELECT 1 FROM `my_table` WHERE `field_x` = 'something' 然后我获取结果: $
我想要的输出的描述:我想要两个线程 Gaurav 和 john 完成一个 while 循环(从 1 到 8),这样无论哪个线程启动 ist,都会运行 5 次迭代(即直到 count=5 ) ,然后进入
我是一名优秀的程序员,十分优秀!