我想获得当月的所有记录,因此我将该月的第一个日期和该月的最后一天的两个谓词堆叠起来.由于我使用CoreData,因此日期实际存储为NSTimeInterval.
NSCalendar *calendar = [NSCalendar currentCalendar];
//Get beginning of current month
NSDateComponents *beginningOfCurrentMonthComponents = [calendar components:(NSEraCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:date];
[beginningOfCurrentMonthComponents setDay:1];
NSDate *beginningOfCurrentMonthDate = [calendar dateFromComponents:beginningOfCurrentMonthComponents];
//Set a single month to be added to the current month
NSDateComponents *oneMonth = [[NSDateComponents alloc] init];
[oneMonth setMonth:1];
//determine the last day of this month
NSDate *beginningOfNextMonthDate = [calendar dateByAddingComponents:oneMonth toDate:beginningOfCurrentMonthDate options:0];
NSMutableArray *parr = [NSMutableArray array];
[parr addObject:[NSPredicate predicateWithFormat:@"recordDate >= %d", [beginningOfCurrentMonthDate timeIntervalSince1970]]];
[parr addObject:[NSPredicate predicateWithFormat:@"recordDate < %d", …Run Code Online (Sandbox Code Playgroud) 我有以下代码产生此错误.我无法理解为什么subarrayWithRange消息被发送到字符串?当它显然是一个阵列?
static const int kItemsPerView = 20;
NSRange rangeForView = NSMakeRange( page * kItemsPerView, kItemsPerView );
NSMutableArray *temp = [[APP_DELEGATE keysArray] mutableCopyWithZone:NULL];
NSArray *itemsForView = [temp subarrayWithRange:rangeForView];
for (int loopCounter = 0;loopCounter < r*c;loopCounter++){
NSLog(@"%i: %@ ", loopCounter, [itemsForView objectAtIndex:loopCounter]);
}
Run Code Online (Sandbox Code Playgroud)
错误:
-[NSCFString subarrayWithRange:]: unrecognized selector sent to instance 0x6b071a0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: [NSCFString subarrayWithRange:]:
Run Code Online (Sandbox Code Playgroud)
谢谢
以下代码是从storyboard向当前视图添加子视图:
EventSearchViewController* view1 = [self.storyboard instantiateViewControllerWithIdentifier:@"searchView"];
[view1 setBookingSystem:system];
[self.view addSubview:view1.view];
Run Code Online (Sandbox Code Playgroud)
在视图"view1"中,有一个textField.以下是textField的IBAction,事件是"退出时结束".
-(IBAction)searchKeyword:(id *)sender
{
NSLog(@"searchKeyword");
}
Run Code Online (Sandbox Code Playgroud)
以下是错误消息.
2012-05-26 20:26:47.369 OnlineBooking [6607:f803] - [__ NSCFType searchKeyword:]:无法识别的选择器发送到实例0x6d8eb80
2012-05-26 20:26:47.369 OnlineBooking [6607:f803] * WebKit在webView中丢弃了一个未捕获的异常:shouldInsertText:replacementDOMRange:givenAction:delegate: - [__ NSCFType searchKeyword:]:发送到实例0x6d8eb80的无法识别的选择器
我在应用程序商店中有一个应用程序,我正在使用Flurry分析.并且我不时会得到一个未处理的异常错误,我无法弄明白.
NSInvalidArgumentException: - [UIBarButtonItem setTintColor:]:发送到实例0x177b20的无法识别的选择器Msg:应用程序崩溃
我无法弄清楚的是,我没有在任何地方设置任何条形按钮项目的色彩.我有一些自定义视图,我设置正确的条形按钮项目,但没有色调.
我对按钮的大多数使用都是这样的.
- (void)viewDidLoad
{
[super viewDidLoad];
UINavigationBar *bar = [self.navigationController navigationBar];
[bar setTintColor:[UIColor colorWithRed:0 green:69.0/255 blue:118.0/255 alpha:1]];
self.navigationItem.title = @"Edit User";
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc]
initWithTitle:@"Save"
style:UIBarButtonItemStylePlain
target:self
action:@selector(editUser:)];
self.navigationItem.rightBarButtonItem = saveButton;
[saveButton release];
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancel)];
[[self navigationItem] setLeftBarButtonItem:cancelButton];
[cancelButton release];
}
Run Code Online (Sandbox Code Playgroud)
如果有人对此问题有任何见解,我将非常感激.我的目标是iOS 4.0以及我的项目.
更新: 我弄清楚是什么导致了setTintColor上的一些随机问题.我发现我在其中一个实际的条形按钮项上设置了色调.我猜测OS版本之间存在一些可能导致崩溃的差异.因此,如果有人能告诉我在导航栏中设置自定义右键栏项目的OS中立方式,我们将不胜感激.
使用UIAppearance代理设置UIBarButtonItem的子类的自定义属性会导致"无法识别的选择器"异常,因为设置器可能正由UIAppearance转发到UINavigationButton,而不是条形按钮本身.
我正在使用带有Xcode 5 DP5的iOS 7 Beta 5 SDK.但请不要告诉我它是在NDA之下,因为我不会在这个问题上讨论任何新功能或新类.我告诉你我的SDK,因为可以发现它只是测试版软件中的一个错误.
我将a子类化UIBarButtonItem并在头文件中创建了一个自定义属性:
@property (nonatomic, strong) NSString *mySubclassedProperty UI_APPEARANCE_SELECTOR;
Run Code Online (Sandbox Code Playgroud)
我的二传手和吸气器看起来像这样:
- (void)setMySubclassedProperty:(NSString *)mySubclassedProperty {
_mySubclassedProperty = mySubclassedProperty;
NSLog(@"%p %s %@", self, __PRETTY_FUNCTION__, mySubclassedProperty);
}
Run Code Online (Sandbox Code Playgroud)
没什么特别的,对吧?但它根本不起作用UIAppearance.当我尝试在我的应用程序的委托中设置默认外观时,它没有给我任何错误,也没有任何警告.
[[AKBarButtonItem appearance] setMySubclassedProperty:@"GLOBALLY ASSIGNED"];
Run Code Online (Sandbox Code Playgroud)
这似乎是工作就像一个魅力,除了使用它崩溃时,我尝试设置的一个实例的事实AKBarButtonItem来self.navigationItem.rightBarButtonItem:
self.navigationItem.rightBarButtonItem = [[AKBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:nil action:nil];
Run Code Online (Sandbox Code Playgroud)
回溯看起来像这样:
2013-08-13 14:30:08.551 UIBarButtonItem Subclass Demo[1512:a0b] -[UINavigationButton setMySubclassedProperty:]: unrecognized selector sent to instance 0x8c42710
2013-08-13 14:30:08.556 UIBarButtonItem Subclass Demo[1512:a0b] *** Terminating app due to uncaught …Run Code Online (Sandbox Code Playgroud) iphone uibarbuttonitem ios unrecognized-selector uiappearance
我一直在经历所有堆栈溢出试图解决这个问题,但没有一个解决方案有效.
class ToastView: UIView {
static func showInParent(parentView: UIView!, withText text: String, forDuration duration: double_t) {
//Count toast views are already showing on parent. Made to show several toasts one above another
var toastsAlreadyInParent = 0;
for view in parentView.subviews {
if (view.isKindOfClass(ToastView)) {
toastsAlreadyInParent++
}
}
var parentFrame = parentView.frame;
var yOrigin = parentFrame.size.height - getDouble(toastsAlreadyInParent)
var selfFrame = CGRectMake(parentFrame.origin.x + 20.0, yOrigin, parentFrame.size.width - 40.0, toastHeight);
var toast = ToastView(frame: selfFrame)
toast.textLabel.backgroundColor = UIColor.clearColor()
toast.textLabel.textAlignment = NSTextAlignment.Center
toast.textLabel.textColor …Run Code Online (Sandbox Code Playgroud) 跳过所有这些信息并跳到底部的更新...
我之前已经处理过无法识别的选择器,但我无法弄清楚这次发生了什么.调用堆栈是不透明的,我无法找出问题的起源.我尝试过使用符号和异常断点.这段代码之前工作得很完美.我再回来研究这个程序了,现在我正在尝试这个
[UITableViewSectionElement numberOfSections]: unrecognized selector sent to instance 0xa285d50
Run Code Online (Sandbox Code Playgroud)
我UITableViews在这个视图控制器中有两个.其中一个被连接起来IB(datasource and delegate).第二个在代码中实例化,其数据源/委托也指向视图控制器.我在第二个tableview上放了一个2的标记,以区分它们.UITableViewTwo添加到a UIView,如果我有要显示的有效数据,它将作为第一个tableview的页脚返回.再一次,这段代码完美地工作,一段时间没有任何崩溃,我似乎无法弄清楚为什么它现在崩溃.我正在使用ARC.
这是一些代码:
当我检查发送选择器的对象的地址是什么时:它确实是一个UITableViewSectionElement.为什么H接收到呼叫号码部分?不应该是numberOfSectionsInTableView吗?
UITableView Delegate/DataSource methods
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView.tag == 0) {
if (indexPath.row == 0) {
PCFCustomNumberReviewsCell *cell = [self.tableViewOne dequeueReusableCellWithIdentifier:@"PCFNumberOfRatings"];
[cell.numberOfReviews setText:[NSString stringWithFormat:@"%d", numReviews.integerValue]];
[cell.numberOfReviews setFont:[PCFFontFactory droidSansFontWithSize:17]];
[cell.numberOfReviews setTextColor:[UIColor lightGrayColor]];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:cell.frame];
[imgView setImage:[UIImage imageNamed:@"1slot2.png"]];
[cell setBackgroundView:imgView];
return cell;
}else if(indexPath.row == 1) {
PCFCustomReviewCell …Run Code Online (Sandbox Code Playgroud) 以下是viewWillAppear
[SYPTableView setSeparatorInset:UIEdgeInsetsZero];
Run Code Online (Sandbox Code Playgroud)
在iOS 7上正常工作但在6.1上它引发了异常:
NSInvalidArgumentException', reason: '-[UITableView setSeparatorInset:]: unrecognized selector sent to instance
Run Code Online (Sandbox Code Playgroud)
我的目的是删除单元格边框.
我有一个UITableView从美联储Core Data与NSFetchedResultsController返回位置的实体.默认排序(和节标题)是通过实体名称的第一个字母.这是有效的(尽管我仍然试图将大小写合并到相同的部分.)用户可以选择按三个可选类别之一(实体的属性)对表进行排序,然后对这些类别进行排序按实体名称.
当我设置按类别排序时,我得到以下运行时错误:
[_TtCSs23_ContiguousArrayStorage00007F80513B59D0 key]: unrecognized selector sent to instance 0x7f80513b5720
Run Code Online (Sandbox Code Playgroud)
这是我的NSFetchedResultsController:
var sectionNameKeyPathString1: String?
var sectionNameKeyPathString2: String?
var fetchedResultsController: NSFetchedResultsController {
if _fetchedResultsController != nil {
return _fetchedResultsController!
}
let fetchRequest = NSFetchRequest()
// Edit the entity name as appropriate.
let entity = NSEntityDescription.entityForName("Location", inManagedObjectContext: self.managedObjectContext!)
fetchRequest.entity = entity
// Set the batch size to a suitable number.
fetchRequest.fetchBatchSize = 20
// Edit the sort key as appropriate.
if sectionNameKeyPathString1 != …Run Code Online (Sandbox Code Playgroud) nssortdescriptor nsfetchedresultscontroller unrecognized-selector sections swift
我试图计算两次之间的持续时间差。我从JSONArray获得持续时间,我使用下面的代码
NSDate *starttime = [[NSDate alloc]init];
NSDate *endtime = [[NSDate alloc]init];
starttime = [currentRecord valueForKey:@"starttime"];
endtime = [currentRecord valueForKey:@"endtime"];
Run Code Online (Sandbox Code Playgroud)
我将上述值传递给另一种方法
+(NSString*)remaningTime:(NSDate*)startDate endDate:(NSDate*)endDate
{
NSDateComponents *components= [[NSDateComponents alloc]init];
NSString *durationString;
components = [[NSCalendar currentCalendar] components: NSCalendarUnitDay/*|NSCalendarUnitHour|NSCalendarUnitMinute*/ fromDate: endDate toDate: startDate options: 0];
}
Run Code Online (Sandbox Code Playgroud)
但我低于例外
-[__ NSCFString timeIntervalSinceReferenceDate]:无法识别的选择器已发送到实例0x78685f80
2016-12-20 15:21:37.361 nexge[1515:183039] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x78685f80'
*** First throw call stack:
(
0 CoreFoundation 0x03abc212 __exceptionPreprocess + 194
1 libobjc.A.dylib …Run Code Online (Sandbox Code Playgroud) ios ×7
objective-c ×5
iphone ×2
swift ×2
ios4 ×1
json ×1
nsarray ×1
nsdate ×1
nspredicate ×1
sections ×1
uiappearance ×1
uitableview ×1