我在构建视图控制器时遇到问题.这是我的appdelegate中的代码片段:
InitViewController *initVC = (InitViewController *)self.window.rootViewController;
VMParentVC *topVC = (VMParentVC *) initVC;
[topVC navigateToMain];
Run Code Online (Sandbox Code Playgroud)
我正在尝试做的是转换rootViewController,以便我能够使用我的VMParentVC类中的方法.但是当我这样做时,我得到这个错误:
"[UINavigationController navigateToMain]:无法识别的选择器发送到实例"
不太确定我做错了什么.
我的帖子通知功能有问题.
在FirstViewController中viewDidLoad我有这样的句子:
NSNotificationCenter.defaultCenter().addObserver(self, selector: "ponresultado", name: "resultadobusqueda", object: nil)
Run Code Online (Sandbox Code Playgroud)
之后我有了这个功能:
func ponresultado(notification:NSNotification)
{
var oDato : oDatoSel = notification.object as oDatoSel
}
Run Code Online (Sandbox Code Playgroud)
在类型的第二视图控制器TableViewController在didDeselectRowAtIndexPath方法我有这样的代码:
var oDato : oDatoSel = oDatoSel()
oDato.id = "1"
oDato.nombre = "test"
NSNotificationCenter.defaultCenter().postNotificationName("resultadobusqueda", object: oDato)
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
[App.FirstViewController ponresultado]: unrecognized selector sent to instance 0x797d2310
Run Code Online (Sandbox Code Playgroud)
如果在我的ponresultado函数中FirstViewController,我退出这样的notification:NSNotification参数:
func ponresultado()
{
var oDato : oDatoSel = notification.object as oDatoSel
}
Run Code Online (Sandbox Code Playgroud)
我没有错误.为什么?
nsnotification nsnotificationcenter ios unrecognized-selector swift
我正在参加斯坦福iOS课程(对不起,我是其中一个人,但我想以某种方式学习)我正在使用的代码与教授关于MKMapViews的代码几乎完全相同但是我得到了这个例外,他没有,我真的无法理解.可能是什么导致了这个?
我得到的例外:
- [NSConcreteData _isResizable]:发送到实例0x90a4c00的无法识别的选择器
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
MKAnnotationView *aView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"MapVC"];
if (!aView) {
aView = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"MapVC"];
aView.canShowCallout=YES;
aView.leftCalloutAccessoryView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
aView.rightCalloutAccessoryView= [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
}
aView.annotation=annotation;
[(UIImageView *)aView.leftCalloutAccessoryView setImage:nil];
return aView;
}
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
UIImage *image = [self.delegate getImageForMapViewController:self withAnnotation:view.annotation];
[(UIImageView *)view.leftCalloutAccessoryView setImage:image]; // this is where I get the exception.
}
Run Code Online (Sandbox Code Playgroud) 嗯,这是一个非常奇怪的问题.(我只是希望它与我不玩的时间有关 - 可以和Cocoa一起玩,或者......)
所以,问题非常简单:
NSProgressIndicator)[NSProgressIndicator start]:无法识别的选择器发送到实例0x7f9f4b91a0a0
#import <Foundation/Foundation.h>
@interface NSProgressIndicator (NSProgressIndicator_Functions)
- (void)start;
- (void)stop;
@end
Run Code Online (Sandbox Code Playgroud)
#import "NSProgressIndicator+Functions.h"
@implementation NSProgressIndicator (NSProgressIndicator_Functions)
- (void)start
{
[self setHidden:NO];
[self startAnimation:nil];
}
- (void)stop
{
[self setHidden:YES];
[self stopAnimation:nil];
}
@end
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
cocoa objective-c unrecognized-selector objective-c-category
我试图从响应中获取数据.
我正在使用NSURLConnectionDelegate,NSURLConnectionDataDelegate.
该项目使用ARC.
@interface MainMenu()
@property (nonatomic, unsafe_unretained) NSMutableData* wpData;
@end
@implementation
-(void)sendRequest{
NSURL* url = [[NSURL alloc] initWithString:@"http://smthing"];
NSMutableURLRequest* request = [[NSMutableURLRequest alloc] init];
NSString* reqBody = @"Block";
NSData* reqData = [reqBody dataUsingEncoding:NSUTF8StringEncoding];
[request setURL:url];
[request setHTTPBody:reqData];
[request setHTTPMethod:@"POST"];
self.wpData = [NSMutableData data];
NSURLConnection* conection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[conection start];
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
//Here iI have [__NSMallocBlock__ appendData:]: unrecognized selector sent to instance 0x95f3fb0
[self.wpData setLength:0];
}
@end
Run Code Online (Sandbox Code Playgroud)
也许你可以找到我的错误
谢谢 …
我正在尝试创建一个视图,其中只有UITableView作为该视图的一部分.我相信这是从代码(而不是界面构建器)创建时的正确模式,但如果我的方法也是错误的,请随意添加建议.
我得到的例外是: [KBSMoreViewController tableView:numberOfRowsInSection:]:发送到实例的无法识别的选择器
我有一个类标题如下(我在实现中实现构造函数):
#import <UIKit/UIKit.h>
@interface KBSMoreTableView : UITableView
- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style;
@end
Run Code Online (Sandbox Code Playgroud)
然后我有一个ViewController类头:
@interface KBSMoreViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@end
Run Code Online (Sandbox Code Playgroud)
ViewController是标签栏的一部分,工作正常(我试图添加的tableview之外)实现如下:
#import "../Models/KBSMoreTableView.h"
@interface KBSMoreViewController ()
@property (strong, nonatomic) KBSMoreTableView* tableView;
@property (strong, nonatomic) NSString* cellIdentifier;
@property (copy, nonatomic) NSArray *source;
@end
@implementation KBSMoreViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMore tag:0];
self.source = [[NSArray alloc] initWithObjects:@"Test1", @"Test2", nil];
self.cellIdentifier = @"MoreCellId";
}
return self; …Run Code Online (Sandbox Code Playgroud) cocoa-touch objective-c uitableview ios unrecognized-selector
我是目标c和iOS的新手.这是我的第一个应用程序,所以请耐心等待.
我只是试图制作一个页面,其中包含一些从文本文件中动态创建的按钮,这将在webview中打开一个页面.
我的代码基于此:如何在UiButton动作中传递任何类型的参数?
MyButton.h
#import <Foundation/Foundation.h>
@interface MyButton : UIButton
{
NSString *_linkURL;
}
@property (nonatomic, retain) NSString *linkURL;
@end
Run Code Online (Sandbox Code Playgroud)
MyButton.m
#import "MyButton.h"
@implementation MyButton
@synthesize linkURL = _linkURL;
@end
Run Code Online (Sandbox Code Playgroud)
那么在我的ViewController.m文件中,我正在导入MyButton并尝试使用它来创建将URL作为自己的属性的按钮.
MyButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchDown];
[button setLinkURL:URL]; //THIS IS THE LINE THATS GIVING ME THE unrecognized selector at instance error
Run Code Online (Sandbox Code Playgroud)
然后我继续在buttonPressed方法中获取URL但我似乎无法通过这一个错误.我不知道我做错了什么.
嗨,我想整合Paypal服务,但它给出错误
错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [PayPalPaymentViewController payPalServiceManager]: unrecocnized selector sent to instance 0x12784450'
Run Code Online (Sandbox Code Playgroud)
代码:
- (IBAction)buttonPaypalAction:(id)sender
{
gateway = @"Paypal";
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [[NSDecimalNumber alloc] initWithString:[appDelegate.orderDetails objectAtIndex:6]];
payment.currencyCode = appDelegate.currencyCode;
payment.shortDescription = @"Food items";
if (!payment.processable) {
// This particular payment will always be processable. If, for
// example, the amount was negative or the shortDescription was
// empty, this payment wouldn't be processable, and you'd want
// to …Run Code Online (Sandbox Code Playgroud) 我搜索过去几个小时但尚未找到答案.我实现了一个AVFoundation摄像头,我将图像数据保存到磁盘并仅存储核心数据中的路径.一切正常,但在随机拍摄照片后,我收到此错误:
CoreData:错误:严重的应用程序错误.在Core Data更改处理期间捕获到异常.这通常是NSManagedObjectContextObjectsDidChangeNotification的观察者中的错误. - [__ NSDate localizedCaseInsensitiveCompare:]:无法识别的选择器发送到实例
这是我的获取请求代码:
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Photo"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"notebook = %@", notebookItem];
[request setPredicate:predicate];
request.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"dateTaken"
ascending:NO
selector:@selector(compare:)]];
Run Code Online (Sandbox Code Playgroud)
以下是我将数据保存在单独的类中的方法:
//I create a photo Object to save to core data and set properties like dateTaken and tittle
//Here is where I create the path name
NSDate *dateString = [[NSDate alloc] init];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS"];
NSString *path = [formatter stringFromDate:dateString];
//Now I save to disk
NSArray …Run Code Online (Sandbox Code Playgroud) core-data objective-c avfoundation ios unrecognized-selector
我独立完成了斯坦福大学的iTunes U编程iOS 7课程,因此我现在有一个问题,我不能问老师,我希望有人可以帮助我.理想情况下,通过告诉我如何追踪这类问题,但我也在http://talix.homeip.net/2014/Matchismo.zip发布我的整个项目(因为我认为我不能有用地发布用户可以在这篇文章中调试它,就像普通的文本代码一样),所以只要告诉我具体问题在哪里也会非常感激!对于任何参加同一课程的人来说,我正处于任务3的中间位置.
我有一个非常基本的卡片匹配游戏,可以玩扑克牌或"设置".扑克牌标签效果很好.只要我按下新游戏按钮或点击卡片(这会导致开始新游戏),"设置"选项卡会以未捕获的异常(下面复制)崩溃.我在我的代码中放了一个断点,以便捕获New Game操作,并逐步完成所有生成的代码.当我踩过我的代码时,这一切似乎都很好.当我到达我的最后一个函数的末尾时,由于操作而被调用,然后我按下XCode中的Continue,这就是它崩溃的时候.鉴于这一事实,我不确定如何追踪导致问题的确切原因.
另一个问题:从异常文本发布整个调用堆栈是否有用,或者顶级耦合行是唯一真正有用的(对于像我这样的初学者)?我想我看到有问题的无法识别的选择器是[__NSCFConstantString _isDefaultFace]:但是我不知道在哪里调用它作为我假设的一部分是我使用的类的类型后面的UI代码(UILabel,等等.).
以下是整个异常文本以防万一:
2014-09-28 18:45:54.337 Matchismo[17292:2714082] -[__NSCFConstantString _isDefaultFace]: unrecognized selector sent to instance 0xc721c
2014-09-28 18:45:54.346 Matchismo[17292:2714082] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString _isDefaultFace]: unrecognized selector sent to instance 0xc721c'
*** First throw call stack:
(
0 CoreFoundation 0x01cfddf6 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x01987a97 objc_exception_throw + 44
2 CoreFoundation 0x01d05a75 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x01c4e9c7 ___forwarding___ + 1047
4 CoreFoundation 0x01c4e58e _CF_forwarding_prep_0 + 14
5 UIFoundation …Run Code Online (Sandbox Code Playgroud) ios ×9
objective-c ×8
cocoa-touch ×2
avfoundation ×1
cocoa ×1
core-data ×1
crash ×1
cs193p ×1
exception ×1
paypal ×1
swift ×1
uibutton ×1
uitableview ×1