在Xcode 8中,Objective-C略有改变.现在有类级属性.例如,NSBundle的标头
@interface NSBundle : NSObject {
...
/* Methods for creating or retrieving bundle instances. */
#if FOUNDATION_SWIFT_SDK_EPOCH_AT_LEAST(8)
@property (class, readonly, strong) NSBundle *mainBundle;
#endif
+ (nullable instancetype)bundleWithPath:(NSString *)path;
- (nullable instancetype)initWithPath:(NSString *)path NS_DESIGNATED_INITIALIZER;
+ (nullable instancetype)bundleWithURL:(NSURL *)url NS_AVAILABLE(10_6, 4_0);
- (nullable instancetype)initWithURL:(NSURL *)url NS_AVAILABLE(10_6, 4_0);
+ (NSBundle *)bundleForClass:(Class)aClass;
+ (nullable NSBundle *)bundleWithIdentifier:(NSString *)identifier;
#if FOUNDATION_SWIFT_SDK_EPOCH_AT_LEAST(8)
@property (class, readonly, copy) NSArray<NSBundle *> *allBundles;
@property (class, readonly, copy) NSArray<NSBundle *> *allFrameworks;
#endif
...
Run Code Online (Sandbox Code Playgroud)
看看,主要包.现在它被声明为property但是带有class关键字.我认为它代表着class level …
XCTest测试功能按字母顺序调用(在Xcode 8之前)。使用Xcode 8,我无法假定系统以哪种顺序调用测试用例。
有人可以照亮它吗?
试图让精灵'PlayButton'的比例继续向上和向下扩展以暗示用户触摸它.似乎无法让它工作.
这是菜单类:
import SpriteKit
class MenuScene: SKScene {
let ScalePBup = SKAction.scaleX(to: 300, y: 300, duration: 10)
let ScalePBdown = SKAction.scaleX(to: -300, y: -300, duration: 10)
//MARK: - Private Instance Variables
private let logo = GameLogo()
private let title = GameTitle()
private let playButton = PlayButton()
private let background = Background()
private let foreground = Foreground()
private let background2 = Background2()
//MARK: - Init
required init ?(coder aDecoder: NSCoder){
super.init(coder:aDecoder)
}
override init(size: CGSize){
super.init(size: size)
}
override func didMove(to …Run Code Online (Sandbox Code Playgroud) 我想共享一个在应用程序中创建的URL文件和一个文本.但它似乎只能共享文本,而不是URL或UIImage.我正在使用的代码:
let sharedVideo = Video(Title: _data[1], VideoID: _data[0], Duration: _data[3], ViewCount: _data[2])
let sharedURL = VideoManager.exportData(video: sharedVideo)
let shareItems:Array = [sharedURL,"check this out baby!"] as [Any]
let activityViewController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil)
self.present(activityViewController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
此外,我使用UIImage对象而不是sharedURL来查看它是否有URL问题.
即使使用图像文件也不起作用.当我点击内部的分享按钮时UIActivityViewController,它只适用于文本,没有URL或图像.我在Xcode 8中使用Swift 3.
谢谢.
PS:我确信sharedURL对象不是nil也不是undefined.
我正在创建一个应用程序,通过使用if else语句检测是否存在与Internet的连接,当有互联网时,除了没有互联网连接之外什么也不做,然后提醒视图说应用程序需要互联网我管理发现可达性但是在我的viewDidLoad()上实现uialertview似乎无法正常工作.我用这个:
public class Reachability {
class func isConnectedToNetwork() -> Bool {
var zeroAddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
zeroAddress.sin_len = UInt8(MemoryLayout.size(ofValue: zeroAddress))
zeroAddress.sin_family = sa_family_t(AF_INET)
let defaultRouteReachability = withUnsafePointer(to: &zeroAddress) {
$0.withMemoryRebound(to: sockaddr.self, capacity: 1) {zeroSockAddress in
SCNetworkReachabilityCreateWithAddress(nil, zeroSockAddress)
}
}
var flags: SCNetworkReachabilityFlags = SCNetworkReachabilityFlags(rawValue: 0)
if SCNetworkReachabilityGetFlags(defaultRouteReachability!, &flags) == false {
return false
}
let isReachable = flags == .reachable
let needsConnection = …Run Code Online (Sandbox Code Playgroud) 自从我将xcode更新为xcode 8后,我收到此警告:
实例方法
application(:didRegisterForRemoteNotificationsWithDeviceToken :)'几乎匹配协议'UIApplicationDelegate的可选要求'application(:didRegisterForRemoteNotificationsWithDeviceToken :)'
Xcode要求我通过将此函数设为私有来使这个警告静音,但是当我这样做时,函数从未被调用过(它不会被调用).
我试图删除功能,然后自动完成填充它,但没有任何效果.
这是有警告的功能:
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
//
}
Run Code Online (Sandbox Code Playgroud)
这是我完整的appDelegate文件:
@UIApplicationMain
class AppDelegate: UIResponder,UIApplicationDelegate,UNUserNotificationCenterDelegate,CLLocationManagerDelegate {
var window: UIWindow?
var locationManager:CLLocationManager?
var coordinate: CLLocationCoordinate2D?
func locationManagerStart() {
if locationManager == nil {
print("init locationManager")
locationManager = CLLocationManager()
locationManager!.delegate = self
locationManager!.desiredAccuracy = kCLLocationAccuracyBest
locationManager!.requestWhenInUseAuthorization()
}
print("have location manager")
locationManager!.startUpdatingLocation()
}
func locationManagerStop() {
locationManager!.stopUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
//
let newLocation = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用这个步骤创建一个框架https://www.raywenderlich.com/65964/create-a-framework-for-ios
我已经将框架文件导入到项目中,我可以为框架文件创建对象并访问方法.但是当我构建项目时,它告诉我找不到文件.
我遇到以下错误
接口生成器文件中的未知类TutorialViewController.swift。
重命名默认的文件时Main.storyboard,并ViewController.swift到我想要的命名规则TutorialView.storyboard和TutorialViewController.swift分别。
我通过重命名Xcode中的文件名并更新的类名来重命名了文件TutorialViewController.swift。
重命名后,我试图修复与链接TutorialView.storyboard到TutorialViewController.swift通过更新故事板是Custom Class给TutorialViewController,这是完成链接的正确方法。实际上,这导致了上述错误。
免责声明:我知道这类似于此SO帖子,但是我想提出这个问题并回答我的解决方案,因为该帖子没有被接受的答案。我希望我能一直花点时间解决这个问题。
我添加了电子邮件建议的密钥,还添加了下拉列表中的密钥。
我清理了项目。我不知所措。
这是来自Apple的电子邮件:
缺少Info.plist键-此应用尝试访问对隐私敏感的数据,而没有使用说明。该应用程序的Info.plist必须包含一个NSAppleMusicUsageDescription键,该键具有字符串值,向用户解释该应用程序如何使用此数据。
xcode8 ×10
ios ×6
swift ×4
swift3 ×4
objective-c ×3
xcode ×2
appcode ×1
autolayout ×1
function ×1
ipad ×1
reachability ×1
sprite-kit ×1
uialertview ×1
xctest ×1
xib ×1