質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

iPhone

iPhoneとは、アップル社が開発・販売しているスマートフォンです。 同社のデジタルオーディオプレーヤーiPodの機能、電話機能、インターネットやメールなどのWeb通信機能の3つをドッキングした機器です。

Q&A

解決済

1回答

1244閲覧

Swift iPhoneアプリにバナー広告を貼りたい

KK.331

総合スコア16

Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

iPhone

iPhoneとは、アップル社が開発・販売しているスマートフォンです。 同社のデジタルオーディオプレーヤーiPodの機能、電話機能、インターネットやメールなどのWeb通信機能の3つをドッキングした機器です。

0グッド

0クリップ

投稿2020/01/16 14:56

編集2020/01/16 15:00

参考元URL
iPhoneアプリにバナー広告を貼れるようにしたいと思っています。
↑の参考ページの手順通りにしているのですが
AppDelegate.swiftの41行目で下記のようなエラーが発生します。
自分なりに調べてみたのですが知識不足で原因がイマイチ分からずこちらに質問させて頂きました。
どうかよろしくお願い致しますm(_ _)m

Xcode11.3 swift -version5.1.3

エラーコード

Swift

1'=' must have consistent whitespace on both sides 2Insert ' ' 3'lazy' must not be used on an already-lazy global 4Replace 'lazy ' with '' 5Use of undeclared type 'NSPersistentContainer'

AppDelegate.swift

Swift

1import UIKit 2import Firebase // ★←追記 3 4@UIApplicationMain 5class AppDelegate: UIResponder, UIApplicationDelegate { 6 7 var window: UIWindow? 8 9 10 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { 11 // Override point for customization after application launch. 12 13 // Use Firebase library to configure APIs ★←追記 14 FirebaseApp.configure() // ★←追記 15 16 // Initialize Google Mobile Ads SDK, application IDを設定 ★←追記 17 GADMobileAds.configure(withApplicationID:"") 18 19 return true 20 } 21 22 23 } 24 25 // MARK: UISceneSession Lifecycle 26 27 func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 28 // Called when a new scene session is being created. 29 // Use this method to select a configuration to create the new scene with. 30 return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 31 } 32 33 func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { 34 // Called when the user discards a scene session. 35 // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 36 // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 37 } 38 39 // MARK: - Core Data stack 40 41lazy var persistentContainer: NSPersistentContainer ={ 42 43 let container = NSPersistentContainer(name: "TTTEST") 44 container.loadPersistentStores(completionHandler: { (storeDescription, error) in 45 if let error = error as NSError? { 46 // Replace this implementation with code to handle the error appropriately. 47 // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 48 49 /* 50 Typical reasons for an error here include: 51 * The parent directory does not exist, cannot be created, or disallows writing. 52 * The persistent store is not accessible, due to permissions or data protection when the device is locked. 53 * The device is out of space. 54 * The store could not be migrated to the current model version. 55 Check the error message to determine what the actual problem was. 56 */ 57 fatalError("Unresolved error (error), (error.userInfo)") 58 } 59 }) 60 return container 61 }() 62 63 // MARK: - Core Data Saving support 64 65 func saveContext () { 66 let context = persistentContainer.viewContext 67 if context.hasChanges { 68 do { 69 try context.save() 70 } catch { 71 // Replace this implementation with code to handle the error appropriately. 72 // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 73 let nserror = error as NSError 74 fatalError("Unresolved error (nserror), (nserror.userInfo)") 75 } 76 } 77 } 78 79

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

'=' must have consistent whitespace on both sides

Insert ' '
'lazy' must not be used on an already-lazy global
Replace 'lazy ' with ''
Use of undeclared type 'NSPersistentContainer'
(Google翻訳)
「=」には、両側に一貫した空白が必要です
「」を挿入
「lazy」は、すでに遅延しているグローバルでは使用できません
'lazy'を ''に置き換えます
未宣言のタイプ「NSPersistentContainer」の使用

上からから4行の指摘は、指摘通りに
lazy var persistentContainer: NSPersistentContainer ={

var persistentContainer: NSPersistentContainer = {
へ変更。
最後の指摘は、NSPersistentContainerの定義が見つからないといっているので、
import CoreDate
を追加してみてください。

投稿2020/01/17 02:59

dsuzuki

総合スコア1682

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

KK.331

2020/01/17 13:42

解決しました! 丁寧な説明ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問