在iPhone 5s上运行时应用程序崩溃,但在模拟器上运行时可以正常运行

时间:2015-03-20 01:20:32

标签: ios xcode sigabrt

我有一个代码可以从网站获取信息并在表格视图中显示。 这是我的代码

  if ([event.eventDescription containsString:@"src="]) {

  NSError *error = nil;
  NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:&error];

  [detector enumerateMatchesInString:event.eventDescription
  options:0
  range:NSMakeRange(0, event.eventDescription.length)
  usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop)
  {
    if (result.resultType == NSTextCheckingTypeLink)
    {
      NSString *str = [NSString stringWithFormat:@"%@",result.URL];
      NSLog(@"Image Url = %@",str);
      event.stringImageURL = str;
    }
  }];

 }

当我在iPhone刺激器上运行此代码时,它可以正常工作。然而,当它在我的iPhone上运行它崩溃。它在此event.stringImageURL = str;代码行中显示SIGABRT错误。有人可以帮助我。

编辑: 这会显示在我的日志中。

-[Events setStringImageURL:]: unrecognized selector sent to instance 0x17002bd40
2015-03-20 09:22:54.047 PforSST1[346:22070] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Events setStringImageURL:]: unrecognized selector sent to instance 0x17002bd40'
*** First throw call stack:
(0x1860ee530 0x1970780e4 0x1860f55f4 0x1860f23ac 0x185ff6c4c 0x100093498 0x187069f34 0x100093114 0x10011cfd4 0x10011cf94 0x100121c28 0x1860a62ec 0x1860a4394 0x185fd11f4 0x18f3fb6fc 0x18a96210c 0x100094a70 0x1976f6a08)
libc++abi.dylib: terminating with uncaught exception of type NSException

这是我的events.h

@interface Events : NSObject

@property (nonatomic, strong) NSString *eventName;
@property (nonatomic, strong) NSString *eventDescription;
@property (nonatomic, strong) NSString *stringImageURL;

@end

这是我的events.m

- (NSComparisonResult)compare:(Events *)otherObject
{
    return [self.eventName compare:otherObject.eventName];
}

0 个答案:

没有答案