1 回答
A couple of things:
In your xib, select the "File Inspector" and make sure your xib deployment version matches your app deployment version. If you don't do this, you will have problems running your application on older deployment versions.
For your crash, if you look in Xcode's debug console, you probably see something that looks like this:
2013-10-31 23:07:10.654 Product[19035:303] *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (WebView)
2013-10-31 23:07:10.654 Product[19035:303] (
0 CoreFoundation 0x00007fff8eeab41c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff97daee75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8eeab2cc +[NSException raise:format:] + 204
3 Foundation 0x00007fff96b83d69 _decodeObjectBinary + 2349
4 Foundation 0x00007fff96b84f2f -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1774
5 Foundation 0x00007fff96b8512b -[NSArray(NSArray) initWithCoder:] + 202
6 Foundation 0x00007fff96b83e22 _decodeObjectBinary + 2534
7 Foundation 0x00007fff96b832dd _decodeObject + 288
8 AppKit 0x00007fff946985bc -[NSView initWithCoder:] + 1949
9 Foundation 0x00007fff96b83e22 _decodeObjectBinary + 2534
10 Foundation 0x00007fff96b832dd _decodeObject + 288
11 AppKit 0x00007fff9469e458 -[NSWindowTemplate initWithCoder:] + 1043
12 Foundation 0x00007fff96b83e22 _decodeObjectBinary + 2534
13 Foundation 0x00007fff96b84f2f -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1774
14 Foundation 0x00007fff96b84567 -[NSSet(NSSet) initWithCoder:] + 203
15 Foundation 0x00007fff96b83e22 _decodeObjectBinary + 2534
16 Foundation 0x00007fff96b832dd _decodeObject + 288
17 AppKit 0x00007fff94670780 -[NSIBObjectData initWithCoder:] + 155
18 Foundation 0x00007fff96b83e22 _decodeObjectBinary + 2534
19 Foundation 0x00007fff96b832dd _decodeObject + 288
20 AppKit 0x00007fff9467059f loadNib + 232
21 AppKit 0x00007fff9466fb9c +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 288
22 AppKit 0x00007fff9466f98c -[NSBundle(NSNibLoading) loadNibNamed:owner:topLevelObjects:] + 197
23 AppKit 0x00007fff9466f77b +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 357
24 AppKit 0x00007fff9466b617 NSApplicationMain + 448
25 Product 0x00000001000012c2 main + 34
26 Product 0x0000000100001294 start + 52
27 ??? 0x0000000000000003 0x0 + 3
)
In this case, this is because the app has no idea what a WebView
is when loading the nib. You to fix this you need to link against the WebKit
framework.
Go back to your target settings and select "Build Phases". Expand "Link Binary With Libraries" and click "+". Search for the Mac WebKit
framework and add it. The app should be able to unarchive the WebView
in the nib now.