をダウンロードしてください。しかし、データがダウンロードされているときにユーザーが最初のビューに戻ると、アプリケーションがクラッシュします。私は私が問題を発見したと思うが、それを固定し、いくつかの助けを必要とする:iPhoneアプリがクラッシュしたビューは、データ中にスワップされている場合、ユーザーがuitableの内の行をクリックしたときに、それが行の値を取り、次のビューを移入するためにウェブからいくつかのデータをダウンロードすることを私はiPhoneアプリを持っている
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSManagedObject *selectedObject = [[self fetchedResultsController] objectAtIndexPath:indexPath];
BlogRssParser *blogRss = [[BlogRssParser alloc] init];
blogRss.terms = [[selectedObject valueForKey:@"data"] description];
RssFunViewController *rssFun = [[RssFunViewController alloc] initWithNibName:@"RssFunViewController" bundle:nil];
rssFun.rssParser = blogRss;
[blogRss release];
[self.navigationController pushViewController:rssFun animated:YES];
rssFun.navigationItem.title=blogRss.terms;
[rssFun release];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
だから、それがダウンロードを終了すると、これは次のコード行であるので、それがクラッシュしたところ、これがある[self.navigationController pushViewController:rssFun animated:YES];
を語りますもしそれが何らかの意味をなすならば、それは正しい画面に表示されていなければビューを押すことができます!とにかくアドバイスありがとう!
BlogRssParser:
-(BOOL)fetchAndParseRss{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
//To suppress the leak in NSXMLParser
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
NSString *urlTerm = terms;
urlTerm = [urlTerm stringByReplacingOccurrencesOfString:@" " withString:@"+"];
urlTerm = [urlTerm stringByReplacingOccurrencesOfString:@"\t" withString:@""];
urlTerm = [urlTerm stringByReplacingOccurrencesOfString:@"&" withString:@""];
urlTerm = [urlTerm stringByReplacingOccurrencesOfString:@"'" withString:@""];
urlTerm = [urlTerm stringByReplacingOccurrencesOfString:@"-" withString:@""];
urlTerm = [urlTerm stringByReplacingOccurrencesOfString:@"_" withString:@""];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"xxxxxxxxxxxxx/app.php?s=%@", urlTerm]];
NSLog(@"%@", url);
BOOL success = NO;
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
[parser setDelegate:self];
[parser setShouldProcessNamespaces:YES];
[parser setShouldReportNamespacePrefixes:YES];
[parser setShouldResolveExternalEntities:NO];
success = [parser parse];
[parser release];
[pool drain];
return success;
}
コンソール:
2010-12-06 19:15:09.826 Example[452:207] -[NSCFString processCompleted]: unrecognized selector sent to instance 0x6123d30
2010-12-06 19:15:09.855 Example[452:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString processCompleted]: unrecognized selector sent to instance 0x6123d30'
*** Call stack at first throw:
(
0 CoreFoundation 0x02664b99 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x027b440e objc_exception_throw + 47
2 CoreFoundation 0x026666ab -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x025d62b6 ___forwarding___ + 966
4 CoreFoundation 0x025d5e72 _CF_forwarding_prep_0 + 50
5 Foundation 0x000423ca __NSThreadPerformPerform + 251
6 CoreFoundation 0x02645faf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
7 CoreFoundation 0x025a439b __CFRunLoopDoSources0 + 571
8 CoreFoundation 0x025a3896 __CFRunLoopRun + 470
9 CoreFoundation 0x025a3350 CFRunLoopRunSpecific + 208
10 CoreFoundation 0x025a3271 CFRunLoopRunInMode + 97
11 GraphicsServices 0x02f4300c GSEventRunModal + 217
12 GraphicsServices 0x02f430d1 GSEventRun + 115
13 UIKit 0x002d1af2 UIApplicationMain + 1160
14 Example 0x0000244a main + 84
15 Example 0x000023ed start + 53
)
terminate called after throwing an instance of 'NSException'
あなたは「それはダウンロードを終了すると、これは次のコード行である」とはどういう意味ですか?あなたが投稿したコード、ダウンロードを開始する場所、または終了時に呼び出されるコードは表示されません。 – filipe
申し訳ありませんBlogRssParserはXMLをフェッチするクラスです。クリックされた行の値が入力され、XMLファイルが戻されて次のビューに移入されます。 – benhowdle89
BlogRssParserにコードを投稿してダウンロードできますか? – aahrens