My Images CD Part 6 - Storing Images in Core Data

Поділитися
Вставка
  • Опубліковано 27 січ 2025

КОМЕНТАРІ • 24

  • @Mahadev-x7u
    @Mahadev-x7u 2 роки тому +1

    That’s amazing lessons… thank you so much Stewart. Best transformable lesson

  • @macmcmillen6282
    @macmcmillen6282 Рік тому

    Would be great to eventually see how this is done using SwiftData rather than Core Data.

    • @StewartLynch
      @StewartLynch  Рік тому +1

      I will be doing something similar with SwiftData in November

    • @macmcmillen6282
      @macmcmillen6282 Рік тому

      @@StewartLynch thanks Stewart. Very much looking forward to it.

  • @THEMMB
    @THEMMB Рік тому

    How do you save multiple images at one time.

    • @StewartLynch
      @StewartLynch  Рік тому

      Sorry, but I don't understand this unless you are talking about selecting multiple images from the album, in which case, you could loop through them and save, but I am not sure how this applies to this example.

  • @victorriurean
    @victorriurean 2 роки тому

    nice

  • @gjermundification
    @gjermundification 2 роки тому

    How would I do this with emails? Transformable conforming to string with dots, string with `@` and dots. For the entity of User, with attribute email of type transformable.

  • @gakkieNL
    @gakkieNL Рік тому

    How do you achieve that the UI scales (smaller) when the keyboard appears?

    • @StewartLynch
      @StewartLynch  Рік тому

      I don’t do anything special. It must be handled by the framework. Can you give me a time stamp in the video where you see this happening?

    • @gakkieNL
      @gakkieNL Рік тому

      @@StewartLynch It happens in my simulator, when I bring up the keyboard the whole form including image shrinks so it fits completely on the screen above the keyboard! Very nice!

    • @StewartLynch
      @StewartLynch  Рік тому

      This is the power of the SwiftUI Layout system and not using fixed sizes.

    • @gakkieNL
      @gakkieNL Рік тому

      @@StewartLynch I’m not seeing this behaviour in my app, but i don’t use a form, so that might be it. I never use fixed sizes…

  • @gakkieNL
    @gakkieNL Рік тому

    I just have the Image as Binary Data and save it like that to Core Data (game.iconImage = selectedImage.jpegData(compressionQuality: 1.0)). CD will also store large images to local storage and small ones in its entirety to CD. Retrieving the image using a helper computed property:
    /// Returns an UIImage for the Game from Core Data (binary data) or the default Image
    var CoreDataImage: UIImage {
    if let imageData = self.iconImage {
    return UIImage(data: imageData) ?? AppImages.gameDefaultImage
    } else {
    return AppImages.gameDefaultImage
    }
    }
    I'm not sure what the benefits are of your approach, or the downfalls of mine ?

    • @StewartLynch
      @StewartLynch  Рік тому

      One of the main objectives of the video was to show how to use transformable as it has many other applications. If your way is working for you, then that is great.

  • @OttoFaerber
    @OttoFaerber 2 роки тому

    Found this ? ua-cam.com/video/rEec1FOjeC8/v-deo.html

    • @StewartLynch
      @StewartLynch  2 роки тому +1

      He is storing as binary data instead of a transformable UIImage. You can choose to do that, but learning how to create transformable objects can help in other implementations as well.

    • @gjermundification
      @gjermundification 2 роки тому

      @@StewartLynch Such as email with validation in place of UIImage? Also I'm sure Transformable is searchable in which may be useful for certain datatypes; not sure about searching in UIImage, perhaps with NSPredicate and CoreML?