3

次の機能がサポートされていることを確認したかったのです。

文字列の配列を UIActivityViewController に送信しようとしている単純なアプリがあります。配列には、属性付きの文字列と通常の文字列が含まれています。共有ボタンをクリックしてメール アプリを開くと、クラッシュしてエラーが発生します。ただし、属性付きの文字列のみを送信すると機能します。

私はこれを IOS6 で試しましたが、問題なく動作します。

構成は次のとおりです。

 NSAttributedString *appName=[[NSAttributedString alloc] initWithString:@"TasteBank\n"     
       attributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:[UIFont  
       systemFontSize]],NSForegroundColorAttributeName:[UIColor brownColor]}];

//crash seen when @"test" added to array without that no crash when mail app opened on ios7

NSMutableArray *dataToShare = [[NSMutableArray alloc ] initWithObjects: appName, @"test", nil];

UIActivityViewController* activityViewController =
        [[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil];

[self presentViewController:activityViewController animated:YES completion:^{}];

これには何か問題がありますか?この構成は IOS7 でサポートされていますか? もしそうなら、これはバグでしょうか?

IOS 7 を搭載した iPhone 4 で実行すると、次のエラーが表示されます。

2013-10-17 11:43:50.609 testing12[2499:60b] -[NSConcreteMutableAttributedString appendString:]:        unrecognized selector sent to instance 0x165ae670
2013-10-17 11:43:50.612 testing12[2499:60b] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMutableAttributedString appendString:]: unrecognized selector sent to instance 0x165ae670' 
First throw call stack:
(0x2ff53f53 0x3a32c6af 0x2ff578e7 0x2ff561d3 0x2fea5598 0x32c389a1 0x328e2f2b 0x328e2bb1 0x328e2791 0x328e23b7 0x328e20dd 0x3284c101 0x3284c101 0x326f9601 0x326f468d 0x326c9a25 0x326c8221 0x2ff1f18b 0x2ff1e65b 0x2ff1ce4f 0x2fe87ce7 0x2fe87acb 0x34ba8283 0x32729a41 0xbd1ed 0x3a834ab7)

XCODE 5 の IOS7.0 シミュレーターで実行すると、次のエラーが表示されます。

2013-10-17 11:23:42.054 testing12[3258:a0b] -[NSConcreteMutableAttributedString appendString:]: unrecognized selector sent to instance 0xa181470
2013-10-17 11:23:42.085 testing12[3258:a0b] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMutableAttributedString appendString:]: unrecognized selector sent to instance 0xa181470'
First throw call stack:
(0   CoreFoundation                      0x017345e4 exceptionPreprocess + 180 
1    libobjc.A.dylib                     0x014b78b6 objc_exception_throw + 44
2   CoreFoundation                      0x017d1903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3   CoreFoundation                      0x0172490b forwarding___ + 1019
4   CoreFoundation                      0x017244ee _CF_forwarding_prep_0 + 14
5   UIKit                               0x008bdfa3 -[UIMailActivity prepareWithActivityItems:] + 2346
6   UIKit                               0x008b9242 -[UIActivityViewController _executeActivity] + 424
7   UIKit                               0x008ba824 -[UIActivityViewController _performActivity:] + 1359
8    libobjc.A.dylib                     0x014c981f -[NSObject performSelector:withObject:] + 70
9   UIKit                               0x0063c75a -[UIActivityGroupViewController collectionView:didSelectItemAtIndexPath:] + 148
10  UIKit                               0x0083929b -[UICollectionView _selectItemAtIndexPath:animated:scrollPosition:notifyDelegate:] + 605
11  UIKit                               0x008516d8 -[UICollectionView _userSelectItemAtIndexPath:] + 189
12  UIKit                               0x00851895 -[UICollectionView touchesEnded:withEvent:] + 437
13  libobjc.A.dylib                     0x014c9874 -[NSObject performSelector:withObject:withObject:] + 77
14  UIKit                               0x00382f92 forwardTouchMethod + 271
15  UIKit                               0x00383002 -[UIResponder touchesEnded:withEvent:] + 30
16  libobjc.A.dylib                     0x014c9874 -[NSObject performSelector:withObject:withObject:] + 77
17  UIKit                               0x00382f92 forwardTouchMethod + 271
18  UIKit                               0x00383002 -[UIResponder touchesEnded:withEvent:] + 30
19  UIKit                               0x0059dd7f _UIGestureRecognizerUpdate + 7166
20  UIKit                               0x00268d4a -[UIWindow _sendGesturesForEvent:] + 1291
21  UIKit                               0x00269c6a -[UIWindow sendEvent:] + 1030
22  UIKit                               0x0023da36 -[UIApplication sendEvent:] + 242
23  UIKit                               0x00227d9f _UIApplicationHandleEventQueue + 11421
24  CoreFoundation                      0x016bd8af CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
25  CoreFoundation                      0x016bd23b __CFRunLoopDoSources0 + 235
26  CoreFoundation                      0x016da30e __CFRunLoopRun + 910
27  CoreFoundation                      0x016d9b33 CFRunLoopRunSpecific + 467
28  CoreFoundation                      0x016d994b CFRunLoopRunInMode + 123
29  GraphicsServices                    0x036859d7 GSEventRunModal + 192
30  GraphicsServices                    0x036857fe GSEventRun + 104
31  UIKit                               0x0022a94b UIApplicationMain + 1225
32  testing12                           0x00002efd main + 141
33  libdyld.dylib                       0x01d70725 start + 0
34  ???                                 0x00000001 0x0 + 1
)
4

2 に答える 2