- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
<分区>
我正在使用一个图书应用程序,用户可以在其中点击一个词,然后将为他们播放包含该词的音频文件的一部分,并且该词将被突出显示。不幸的是,我现在尝试优化代码,从仅支持 iOS8 到支持 iOS7,现在我遇到了一些错误。
这是我得到的错误:
2015-06-10 10:42:50.455 Chi Shin får en hund[63976:607] selected :sammen -- <_UITextKitTextPosition: 0x7862b8b0> (28B)
2015-06-10 10:42:50.456 Chi Shin får en hund[63976:607] -[__NSCFString containsString:]: unrecognized selector sent to instance 0x78f585a0
2015-06-10 10:42:50.458 Chi Shin får en hund[63976:607] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString containsString:]: unrecognized selector sent to instance 0x78f585a0'
*** First throw call stack:
(
0 CoreFoundation 0x023371e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x020b68e5 objc_exception_throw + 44
2 CoreFoundation 0x023d4243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0232750b ___forwarding___ + 1019
4 CoreFoundation 0x023270ee _CF_forwarding_prep_0 + 14
5 Chi Shin faÃär en hund 0x000ab695 -[DataViewController pageWordTapped:] + 805
6 UIKit 0x015384f4 _UIGestureRecognizerSendActions + 230
7 UIKit 0x01537168 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 383
8 UIKit 0x01538bdd -[UIGestureRecognizer _delayedUpdateGesture] + 60
9 UIKit 0x0153c13d ___UIGestureRecognizerUpdate_block_invoke + 57
10 UIKit 0x0153c0be _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 317
11 UIKit 0x015327ac _UIGestureRecognizerUpdate + 199
12 UIKit 0x011dda5a -[UIWindow _sendGesturesForEvent:] + 1291
13 UIKit 0x011de971 -[UIWindow sendEvent:] + 1021
14 UIKit 0x011b05f2 -[UIApplication sendEvent:] + 242
15 UIKit 0x0119a353 _UIApplicationHandleEventQueue + 11455
16 CoreFoundation 0x022c077f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
17 CoreFoundation 0x022c010b __CFRunLoopDoSources0 + 235
18 CoreFoundation 0x022dd1ae __CFRunLoopRun + 910
19 CoreFoundation 0x022dc9d3 CFRunLoopRunSpecific + 467
20 CoreFoundation 0x022dc7eb CFRunLoopRunInMode + 123
21 GraphicsServices 0x0380a5ee GSEventRunModal + 192
22 GraphicsServices 0x0380a42b GSEventRun + 104
23 UIKit 0x0119cf9b UIApplicationMain + 1225
24 Chi Shin faÃär en hund 0x000dad2a main + 138
25 libdyld.dylib 0x030606d9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
函数如下,在 iOS8 中完美运行,这就是我调用该方法的方式。
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pageWordTapped:)];
gestureRecognizer.cancelsTouchesInView = NO;
[self.pageLabel addGestureRecognizer:gestureRecognizer];
和函数。
- (void) pageWordTapped:(UITapGestureRecognizer *)recognizer{
UITextView *textView = (UITextView *)recognizer.view;
CGPoint location = [recognizer locationInView:textView];
// NSLog(@"Tap Gesture Coordinates: %.2f %.2f -- %@", location.x, location.y,textView.text);
CGPoint position = CGPointMake(location.x, location.y);
//get location in text from textposition at point
UITextPosition *tapPosition = [textView closestPositionToPoint:position];
//fetch the word at this position (or nil, if not available)
UITextRange *textRange = [textView.tokenizer rangeEnclosingPosition:tapPosition withGranularity:UITextGranularityWord inDirection:UITextLayoutDirectionRight];
NSString *tappedSentence = [textView textInRange:textRange];
NSLog(@"selected :%@ -- %@",tappedSentence,tapPosition);
if (!togglePlayIsOn) {
for (int i = 0; i < wordArray.count; i ++) {
WordModel *wordModel = wordArray[i];
if ((wordModel.word.length - tappedSentence.length) < 3 && [wordModel.word containsString:tappedSentence]) {
double timeInterval = [wordModel.endTime doubleValue] - [wordModel.startTime doubleValue];
NSTimeInterval intervalForTimer = timeInterval;
NSLog(@"timeInterval :%@, %@, %f", wordModel.startTime, wordModel.endTime, intervalForTimer);
[NSTimer scheduledTimerWithTimeInterval:0.0
target:self
selector:@selector(highlightWord:)
userInfo:@{@"rangeLocation": wordModel.rangeLocation, @"rangeLength": wordModel.rangeLength}
repeats:NO];
[NSTimer scheduledTimerWithTimeInterval:intervalForTimer
target:self
selector:@selector(unHighlightEndOfText:)
userInfo:@{@"wordLength": [NSNumber numberWithInt:1]}
repeats:NO];
[self playWord:[wordModel.startTime doubleValue] endTime:[wordModel.endTime doubleValue]];
return;
}
}
}
}
如果我对 if (!togglePlayIsOn)
语句进行注释,那么应用程序不会崩溃,因此我相信正是在该段代码中发生了错误。
我正在试用 FCM 消息服务。我已经设置了一切完善。当我收到来自 FCM 的消息时,出现以下错误。我不确定这里出了什么问题: AnyHashable("google.c.a.c_id"): 15865
我从服务器获取数据。我的应用程序在 Sinulator 和测试设备 iPhone 4s 中运行良好,但有人在 iPod 4 上遇到问题。他遇到异常: -[__NSCFString objectForK
现在我知道这意味着它正在尝试获取 NSString 中的所有键,这是不可能的。但是,我不知道为什么我的字典是 NSString。 return [requestManager POST:@"/api/
我正在创建UITableview并添加两个UITableviewCell自定义单元格(ProductCell和DescripotionCell)。我正在将数据显示到UILabel中。但是我遇到了这个错
希望简单地将解析图像的URL转换为字符串,以便可以使用SDWebImage进行缓存等。 经过研究,我发现可以通过在NSURL上调用absoluteString将URL从字符串转换为字符串。我也尝试过这
执行这段代码时 FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init]; dialog.fromViewController = view
我收到一个奇怪的排序错误。我有一个名为 wordArrayDuplicates 的数组中的范围列表。我需要根据范围位置对该数组进行排序,因此我将字符串转换为 NSNumber 但它不会进行比较。 *
我正在尝试将录制的视频转换为 mp4,然后将其上传到我的服务器。我遇到了类型转换值(value)观的问题,并到处寻找解决方案。该应用程序在某个时刻崩溃,我继续收到“无法将类型‘__NSCFString
我想访问另一个 json 中我的 Json 的一些数据 这是我的代码: let extraData = userInfo["extraData"] as! [String : Any] print(e
我遇到了这个错误,但我正在尝试从 Dictionary 中获取 String。这是我的代码: FIRDatabase.database().reference().child("users").chi
我遇到了这个错误,但我正在尝试从 Dictionary 中获取 String。这是我的代码: FIRDatabase.database().reference().child("users").chi
我的应用程序中有一个代表用户的类 OtherUser .这个类包含几个 NSString *特性。当我用静态 @"string" 分配这些属性时字符串,属性保存为__NSCFConstantStrin
当我在我的 TableView 中搜索数据时遇到此崩溃。我正在使用文本字段作为搜索栏。这是我的代码: NSMutableArray *searchArray; NSString *searchText
这正在出现。 我正在使用 CoreLocation。 谷歌搜索 setLocationPingTimer 没有显示任何内容。 最佳答案 您正在将 setLocationPingTimer: 消息发送到
我在一个名为 MYVideo 的类中使用 MPMoviePlayerController。这是代码: #import #import "MYVideo.h" @interface MYVideo()
我遇到了一个核心数据错误,我不知道如何修复。 我基本上是将对象的所有数据提取到字典中,将数据显示到表单中,一些字段允许编辑,然后尝试在提交时将数据存储回对象。 但是,在设置所有新的/更新的值时我得到了
我在将 NSData 转换为 UIImage 时遇到问题。 我从设备摄像头捕获图像,并将该图像转换为 NSData 以使用 BLOB 数据类型将其存储在 SQLite 中。 图像数据已成功存储在数据库
我正在从 Mssql 中提取数据。我想将从数据库收到的数据打印到 TableView ,但收到错误“无法将类型'__NSCFString'(0x7fff87a89460)的值转换为'NSArray'(
我一直无法将项目添加到可变数组并让这些项目填充 UITableView。它们目前填充得很好,但在我添加一项后,我在 [reloadData]; 调用中收到“Unrecognized Selector
我已经准备好通过谷歌尝试多种解决方案,但我遇到了两种错误,通过解决方案我得到了这个 2015-08-06 18:52:33.110 FastFast[2824:110493] * Terminatin
我是一名优秀的程序员,十分优秀!