Tag: select器

Swift Multi-arg Selector没有被调用

这是在Objective-C中正常运行的代码, [dataFetcher fetchDataWithRequest:authorizeRequest delegate:self didFinishSelector:@selector(didReceiveRequestToken:data:) didFailSelector:@selector(didFailOAuth:error:)]; 它在Objective-C中调用这两种方法。 但是当我在Swift中使用Selector时,它不起作用。 dataFetcher?.fetchDataWithRequest(requestTokenRequest, delegate: self, didFinishSelector:Selector("didReceiveRequestToken:data:"), didFailSelector: Selector("didFailOAuth:error:")) 这里我打电话的方法, func didReceiveRequestToken(ticket:OAServiceTicket,data:NSData){ } 我已经使用StackOverFlow给出的解决scheme,但他们没有为我工作。 提前致谢。

视图控制器URL请求和连接正确完成后崩溃

我的应用程序进入一个视图控制器,使两个自动服务器请求,使连接,检索数据并正确显示它,并完成。 用户点击一个“喜欢”button,另外两个服务器请求成功。 显示是正确的。 需要被完成。 然后崩溃,错误: [__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 我使用了非常方便的SimplePost类(Nicolas Goles)。 这是我的请求,这两个请求都在viewDidLoad中调用: – (void) setScore { Profile *newPf = [[Profile alloc] initID:thisUser profil:@"na" scor:score]; NSMutableURLRequest *reqPost = [SimplePost urlencodedRequestWithURL:[NSURL URLWithString:kMyProfileURL] andDataDictionary:[newPf toDictPf]]; (void) [[NSURLConnection alloc] initWithRequest:reqPost delegate:self]; } – (void) saveHist { History *newH = [[History alloc] initHistID:thisUser hQid:thisQstn hPts:score hLiked:NO]; NSMutableURLRequest […]

从iPhone中的Sqllite数据库中获取图像

我想要保存在数据库中的图像,并在数据库中获取图像。我在NSData中转换图像,图像存储在数据库中成功,但是当我从数据库中获取图像,然后crash.it这个警告 警告: – [__ NSCFString bytes]:无法识别的select器发送到实例0x7916000 下面的代码用于保存数据库中的图像 NSData *dataImage1 = UIImagePNGRepresentation(image3.image); NSString *str = [NSString stringWithFormat:@"Insert into Gallery(ImageName) VALUES ('%@')",dataImage1]; [Database executeQuery:str]; //Database.m +(NSString* )getDatabasePath{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"Database"]; return writableDBPath; } +(NSMutableArray *)executeQuery:(NSString*)str{ sqlite3_stmt *statement= nil; sqlite3 *database; NSString *strPath = [self […]

在使用委托的ObjectiveC中,如何在不使用UIButton的情况下发送消息?

我最近学会了使用委托从一个类发送消息到另一个每当button被按下,我想找出如何发送消息没有button的动作。 苹果文档build议一个可能的方法是performSelector:(SEL)aSelector; 但是当我尝试使用它时,我没有运气。 相反,这是我所尝试的。 在MicroTune.h中 ,我定义了一个委托并给它一个属性 @class Synth; @protocol TuningDelegate <NSObject> -(void)setTuning:(NSData *)tuningData; @end @interface MicroTune : NSObject { … } @property (assign) id<TuningDelegate> delegate; @end 在Synth.h中 ,我声明了这个类作为委托 #import "MicroTune.h" @interface Synth : NSObject <TuningDelegate> 在Synth.m中 ,我创build了一个让我知道消息到达的方法 #import "Synth.h" – (void)setTuning:(NSData *)tuningData { NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithData:tuningData]; NSLog(@" hip hip %@", array); } 编辑 […]

如何testingUIControlEvents是否被触发

我有一个库实现自定义UIControl与一个方法,将调用.valueChanged事件时调用。 我想testing该行为的方法。 我的自定义控件: class MyControl: UIControl { func fire() { sendActions(for: .valueChanged) } } 和testing: import XCTest class ControlEventObserver: NSObject { var expectation: XCTestExpectation! init(expectation anExpectation: XCTestExpectation) { expectation = anExpectation } func observe() { expectation.fulfill() } } class Tests: XCTestCase { func test() { let myExpectation = expectation(description: "event fired") let observer = ControlEventObserver(expectation: […]

UITableView didSelectRowAtIndexPath从不调用

我有UITableView里面的UIViewController采用UITableViewDelegate & UITableViewDataSource协议。 numberOfRowsInSection和cellForRowAtIndexPath被实现。 故事板中有数据源和代表的出口。 TableViewselect单一select。 检查触摸时显示select。 我在模拟器上运行项目,触摸表单元格,得到了didHighlightRowAtIndexPath调用,但didSelectRowAtIndexPath或willSelectRowAtIndexPath永远不会被调用。 我忘了什么 什么可以影响TableView这种方式? PS我知道,有这样的问题很多,但我已经花了几个小时的谷歌search和阅读stackoverflow,仍然没有解决我的问题。 TestViewController.h: @interface TestViewController : ViewController <UITableViewDelegate, UITableViewDataSource> @end TestViewController.m: @interface TestViewController () @property (strong) IBOutlet UITableView *tableView; @end @implementation TestViewController – (void)viewDidLoad { [super viewDidLoad]; } – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"selected"); } – (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"highlighted"); } – (NSInteger)numberOfSectionsInTableView:(UITableView […]

iOS使用NSTimers向select器发送参数

有没有办法通过NSTimer发送参数给select器? myTimer =[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(removeTheNote:) userInfo:nil repeats:NO]; – (void)removeTheNote:(NSString*)note { NSLog(@"Note %@ ———– REMOVED!",note); } 我知道使用: myTimer =[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(removeTheNote:myNote) userInfo:nil repeats:NO]; 不起作用,所以我问,有没有办法做到这一点?

核心数据错误: – :无法识别的select器发送到实例

我有一个自定义的类MyClass基本上由几个NSMutableArrays组成,没有其他variables。 我有一个实体MyEntity具有MyClass的伊娃。 当我尝试保存实体时,我得到这个堆栈转储: 0 CoreFoundation 0x0118ebe9 __exceptionPreprocess + 185 1 libobjc.A.dylib 0x012e35c2 objc_exception_throw + 47 2 CoreFoundation 0x011906fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 3 CoreFoundation 0x01100366 ___forwarding___ + 966 4 CoreFoundation 0x010fff22 _CF_forwarding_prep_0 + 50 5 Foundation 0x00091bf6 _encodeObject + 1076 6 Foundation 0x0009d041 +[NSKeyedArchiver archivedDataWithRootObject:] + 206 7 CoreData 0x00eb7255 -[NSSQLiteConnection execute] + 2677 8 […]

无法select注释?

我在地图视图上有一个注释。 我可以select它,但是我点击它没有任何反应。 你可以帮帮我吗? 有没有人遇到类似的问题? 这里是build立阴谋的方法: – (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.draggable=YES; aView.leftCalloutAccessoryView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)]; // could put a rightCalloutAccessoryView here } aView.annotation = annotation; [(UIImageView *)aView.leftCalloutAccessoryView setImage:nil]; return aView; } 并将它们添加到地图视图: – […]

parsingSwift IOS – PFCloud callFunctionInBackgroundselect器未被调用

当我从正常调用PFcloud函数返回正确的计数如何,当我调用select器,select器callback函数不会被触发, 欣赏是否有任何可以指向我什么是我的代码中的错误。 工作模块 – 成功打印计数 PFCloud.callFunctionInBackground(CloudFunctions.getBookingCount, withParameters: ["camp": "pmAwLDTNc6"], block: { (result: AnyObject!, error: NSError!) -> Void in if ( error === nil) { NSLog("Booking Count call back: \(result) ") } else if (error != nil) { NSLog("error in helloWorld: \(error.userInfo)") } }) 不工作块(select器) – select器function未被调用 PFCloud.callFunctionInBackground(CloudFunctions.getBookingCount, withParameters: ["camp": "pmAwLDTNc6"], target: self, selector: "block:") func […]