UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Project 38

Forums > Swift

Hey, i've faced with some problem doing project 38, core data. https://www.hackingwithswift.com/read/38/4/creating-an-nsmanagedobject-subclass-with-xcode - here First one is with the func fetchCommits(). "@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes" another one is Cannot find 'JSON' in scope

[https://www.notion.so/fetchCommits-9b2f6fce73b74e74a1c0a0779aef5724] Somebody know how to fix that? and why i have got the mistakes here ?

3      

For the first error. Is the @objc func fetchCommits() in the class ViewController? if it is then resolving the other errors may make it go away. (sometime xcode is not helpful with errors)

For the "Cannot find 'JSON' in scope". Have you put the SwiftyJSON.swift in the project as public init(parseJSON jsonString: String) of public struct JSON is in that file?

Last error Value of type 'ViewController' has no member 'saveContext'. You should have in the class ViewController this func

func saveContext() {
  if container.viewContext.hasChanges {
    do {
      try container.viewContext.save()
    } catch {
              print("An error occurred while saving: \(error.localizedDescription)")
    }
  }
}

4      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.