数据持久化方案解析(二十二) —— SwiftUI App中Core Data和CloudKit之间的数据共享(二)

版本记录

版本号 时间
V1.0 2022.05.30 星期一

前言

数据的持久化存储是移动端不可避免的一个问题,很多时候的业务逻辑都需要我们进行本地化存储解决和完成,我们可以采用很多持久化存储方案,比如说plist文件(属性列表)、preference(偏好设置)、NSKeyedArchiver(归档)、SQLite 3CoreData,这里基本上我们都用过。这几种方案各有优缺点,其中,CoreData是苹果极力推荐我们使用的一种方式,我已经将它分离出去一个专题进行说明讲解。这个专题主要就是针对另外几种数据持久化存储方案而设立。
1. 数据持久化方案解析(一) —— 一个简单的基于SQLite持久化方案示例(一)
2. 数据持久化方案解析(二) —— 一个简单的基于SQLite持久化方案示例(二)
3. 数据持久化方案解析(三) —— 基于NSCoding的持久化存储(一)
4. 数据持久化方案解析(四) —— 基于NSCoding的持久化存储(二)
5. 数据持久化方案解析(五) —— 基于Realm的持久化存储(一)
6. 数据持久化方案解析(六) —— 基于Realm的持久化存储(二)
7. 数据持久化方案解析(七) —— 基于Realm的持久化存储(三)
8. 数据持久化方案解析(八) —— UIDocument的数据存储(一)
9. 数据持久化方案解析(九) —— UIDocument的数据存储(二)
10. 数据持久化方案解析(十) —— UIDocument的数据存储(三)
11. 数据持久化方案解析(十一) —— 基于Core Data 和 SwiftUI的数据存储示例(一)
12. 数据持久化方案解析(十二) —— 基于Core Data 和 SwiftUI的数据存储示例(二)
13. 数据持久化方案解析(十三) —— 基于Unit Testing的Core Data测试(一)
14. 数据持久化方案解析(十四) —— 基于Unit Testing的Core Data测试(二)
15. 数据持久化方案解析(十五) —— 基于Realm和SwiftUI的数据持久化简单示例(一)
16. 数据持久化方案解析(十六) —— 基于Realm和SwiftUI的数据持久化简单示例(二)
17. 数据持久化方案解析(十七) —— 基于NSPersistentCloudKitContainer的Core Data和CloudKit的集成示例(一)
18. 数据持久化方案解析(十八) —— 基于NSPersistentCloudKitContainer的Core Data和CloudKit的集成示例(二)
19. 数据持久化方案解析(十九) —— 基于批插入和存储历史等高效CoreData使用示例(一)
20. 数据持久化方案解析(二十) —— 基于批插入和存储历史等高效CoreData使用示例(二)
21. 数据持久化方案解析(二十一) —— SwiftUI App中Core Data和CloudKit之间的数据共享(一)

源码

1. Swift

首先看下工程组织结构

下面一起看下源码

1. CoreDataStack.swift
import CoreData
import CloudKit

final class CoreDataStack: ObservableObject {
  static let shared = CoreDataStack()

  var ckContainer: CKContainer {
    let storeDescription = persistentContainer.persistentStoreDescriptions.first
    guard let identifier = storeDescription?.cloudKitContainerOptions?.containerIdentifier else {
      fatalError("Unable to get container identifier")
    }
    return CKContainer(identifier: identifier)
  }

  var context: NSManagedObjectContext {
    persistentContainer.viewContext
  }

  var privatePersistentStore: NSPersistentStore {
    guard let privateStore = _privatePersistentStore else {
      fatalError("Private store is not set")
    }
    return privateStore
  }

  var sharedPersistentStore: NSPersistentStore {
    guard let sharedStore = _sharedPersistentStore else {
      fatalError("Shared store is not set")
    }
    return sharedStore
  }

  lazy var persistentContainer: NSPersistentCloudKitContainer = {
    let container = NSPersistentCloudKitContainer(name: "MyTravelJournal")

    guard let privateStoreDescription = container.persistentStoreDescriptions.first else {
      fatalError("Unable to get persistentStoreDescription")
    }
    let storesURL = privateStoreDescription.url?.deletingLastPathComponent()
    privateStoreDescription.url = storesURL?.appendingPathComponent("private.sqlite")
    let sharedStoreURL = storesURL?.appendingPathComponent("shared.sqlite")
    guard let sharedStoreDescription = privateStoreDescription.copy() as? NSPersistentStoreDescription else {
      fatalError("Copying the private store description returned an unexpected value.")
    }
    sharedStoreDescription.url = sharedStoreURL

    guard let containerIdentifier = privateStoreDescription.cloudKitContainerOptions?.containerIdentifier else {
      fatalError("Unable to get containerIdentifier")
    }
    let sharedStoreOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: containerIdentifier)
    sharedStoreOptions.databaseScope = .shared
    sharedStoreDescription.cloudKitContainerOptions = sharedStoreOptions
    container.persistentStoreDescriptions.append(sharedStoreDescription)

    container.loadPersistentStores { loadedStoreDescription, error in
      if let error = error as NSError? {
        fatalError("Failed to load persistent stores: \(error)")
      } else if let cloudKitContainerOptions = loadedStoreDescription.cloudKitContainerOptions {
        guard let loadedStoreDescritionURL = loadedStoreDescription.url else {
          return
        }

        if cloudKitContainerOptions.databaseScope == .private {
          let privateStore = container.persistentStoreCoordinator.persistentStore(for: loadedStoreDescritionURL)
          self._privatePersistentStore = privateStore
        } else if cloudKitContainerOptions.databaseScope == .shared {
          let sharedStore = container.persistentStoreCoordinator.persistentStore(for: loadedStoreDescritionURL)
          self._sharedPersistentStore = sharedStore
        }
      }
    }

    container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
    container.viewContext.automaticallyMergesChangesFromParent = true
    do {
      try container.viewContext.setQueryGenerationFrom(.current)
    } catch {
      fatalError("Failed to pin viewContext to the current generation: \(error)")
    }

    return container
  }()

  private var _privatePersistentStore: NSPersistentStore?
  private var _sharedPersistentStore: NSPersistentStore?
  private init() {}
}

// MARK: Save or delete from Core Data
extension CoreDataStack {
  func save() {
    if context.hasChanges {
      do {
        try context.save()
      } catch {
        print("ViewContext save error: \(error)")
      }
    }
  }

  func delete(_ destination: Destination) {
    context.perform {
      self.context.delete(destination)
      self.save()
    }
  }
}

// MARK: Share a record from Core Data
extension CoreDataStack {
  func isShared(object: NSManagedObject) -> Bool {
    isShared(objectID: object.objectID)
  }

  func canEdit(object: NSManagedObject) -> Bool {
    return persistentContainer.canUpdateRecord(forManagedObjectWith: object.objectID)
  }

  func canDelete(object: NSManagedObject) -> Bool {
    return persistentContainer.canDeleteRecord(forManagedObjectWith: object.objectID)
  }

  func isOwner(object: NSManagedObject) -> Bool {
    guard isShared(object: object) else { return false }
    guard let share = try? persistentContainer.fetchShares(matching: [object.objectID])[object.objectID] else {
      print("Get ckshare error")
      return false
    }
    if let currentUser = share.currentUserParticipant, currentUser == share.owner {
      return true
    }
    return false
  }

  func getShare(_ destination: Destination) -> CKShare? {
    guard isShared(object: destination) else { return nil }
    guard let shareDictionary = try? persistentContainer.fetchShares(matching: [destination.objectID]),
      let share = shareDictionary[destination.objectID] else {
      print("Unable to get CKShare")
      return nil
    }
    share[CKShare.SystemFieldKey.title] = destination.caption
    return share
  }

  private func isShared(objectID: NSManagedObjectID) -> Bool {
    var isShared = false
    if let persistentStore = objectID.persistentStore {
      if persistentStore == sharedPersistentStore {
        isShared = true
      } else {
        let container = persistentContainer
        do {
          let shares = try container.fetchShares(matching: [objectID])
          if shares.first != nil {
            isShared = true
          }
        } catch {
          print("Failed to fetch share for \(objectID): \(error)")
        }
      }
    }
    return isShared
  }
}
2. CloudSharingController.swift
import CloudKit
import SwiftUI

struct CloudSharingView: UIViewControllerRepresentable {
  let share: CKShare
  let container: CKContainer
  let destination: Destination

  func makeCoordinator() -> CloudSharingCoordinator {
    CloudSharingCoordinator(destination: destination)
  }

  func makeUIViewController(context: Context) -> UICloudSharingController {
    share[CKShare.SystemFieldKey.title] = destination.caption
    let controller = UICloudSharingController(share: share, container: container)
    controller.modalPresentationStyle = .formSheet
    controller.delegate = context.coordinator
    return controller
  }

  func updateUIViewController(_ uiViewController: UICloudSharingController, context: Context) {
  }
}

final class CloudSharingCoordinator: NSObject, UICloudSharingControllerDelegate {
  let stack = CoreDataStack.shared
  let destination: Destination
  init(destination: Destination) {
    self.destination = destination
  }

  func itemTitle(for csc: UICloudSharingController) -> String? {
    destination.caption
  }

  func cloudSharingController(_ csc: UICloudSharingController, failedToSaveShareWithError error: Error) {
    print("Failed to save share: \(error)")
  }

  func cloudSharingControllerDidSaveShare(_ csc: UICloudSharingController) {
    print("Saved the share")
  }

  func cloudSharingControllerDidStopSharing(_ csc: UICloudSharingController) {
    if !stack.isOwner(object: destination) {
      stack.delete(destination)
    }
  }
}
3. AddDestinationView.swift
import SwiftUI

struct AddDestinationView: View {
  @Environment(\.presentationMode) var presentationMode
  @Environment(\.managedObjectContext) var managedObjectContext
  @State private var caption: String = ""
  @State private var details: String = ""
  @State private var inputImage: UIImage?
  @State private var image: Image?
  @State private var showingImagePicker = false
  private var stack = CoreDataStack.shared

  var body: some View {
    NavigationView {
      Form {
        Section {
          TextField("Caption", text: $caption)
        } footer: {
          Text("Caption is required")
            .font(.caption)
            .foregroundColor(caption.isBlank ? .red : .clear)
        }

        Section {
          TextEditor(text: $details)
        } header: {
          Text("Description")
        } footer: {
          Text("Description is required")
            .font(.caption)
            .foregroundColor(details.isBlank ? .red : .clear)
        }

        Section {
          if image == nil {
            Button {
              self.showingImagePicker = true
            } label: {
              Text("Add a photo")
            }
          }

          image?
            .resizable()
            .scaledToFit()
        } footer: {
          Text("Photo is required")
            .font(.caption)
            .foregroundColor(image == nil ? .red : .clear)
        }

        Section {
          Button {
            createNewDestination()
            presentationMode.wrappedValue.dismiss()
          } label: {
            Text("Save")
          }
          .disabled(caption.isBlank || details.isBlank || image == nil)
        }
      }
      .sheet(isPresented: $showingImagePicker, onDismiss: loadImage) {
        ImagePicker(image: $inputImage)
      }
      .navigationTitle("Add Destination")
    }
  }
}

// MARK: Loading image and creating a new destination
extension AddDestinationView {
  private func loadImage() {
    guard let inputImage = inputImage else { return }
    image = Image(uiImage: inputImage)
  }

  private func createNewDestination() {
    let destination = Destination(context: managedObjectContext)
    destination.id = UUID()
    destination.createdAt = Date.now
    destination.caption = caption
    destination.details = details
    let imageData = inputImage?.jpegData(compressionQuality: 0.8)
    destination.image = imageData
    stack.save()
  }
}

struct AddDestinationView_Previews: PreviewProvider {
  static var previews: some View {
    AddDestinationView()
  }
}
4. HomeView.swift
import SwiftUI

struct HomeView: View {
  @State private var showAddDestinationSheet = false
  @Environment(\.managedObjectContext) var managedObjectContext
  @FetchRequest(sortDescriptors: [SortDescriptor(\.createdAt, order: .reverse)])
  var destinations: FetchedResults<Destination>
  private let stack = CoreDataStack.shared

  var body: some View {
    NavigationView {
      // swiftlint:disable trailing_closure
      VStack {
        List {
          ForEach(destinations, id: \.objectID) { destination in
            NavigationLink(destination: DestinationDetailView(destination: destination)) {
              VStack(alignment: .leading) {
                Image(uiImage: UIImage(data: destination.image ?? Data()) ?? UIImage())
                  .resizable()
                  .scaledToFill()

                Text(destination.caption)
                  .font(.title3)
                  .foregroundColor(.primary)

                Text(destination.details)
                  .font(.callout)
                  .foregroundColor(.secondary)
                  .multilineTextAlignment(.leading)

                if stack.isShared(object: destination) {
                  Image(systemName: "person.3.fill")
                    .resizable()
                    .scaledToFit()
                    .frame(width: 30)
                }
              }
            }
            .swipeActions(edge: .trailing, allowsFullSwipe: false) {
              Button(role: .destructive) {
                stack.delete(destination)
              } label: {
                Label("Delete", systemImage: "trash")
              }
              .disabled(!stack.canDelete(object: destination))
            }
          }
        }
        Spacer()
        Button {
          showAddDestinationSheet.toggle()
        } label: {
          Text("Add Destination")
        }
        .buttonStyle(.borderedProminent)
        .padding(.bottom, 8)
      }
      .emptyState(destinations.isEmpty, emptyContent: {
        VStack {
          Text("No destinations quite yet")
            .font(.headline)
          Button {
            showAddDestinationSheet.toggle()
          } label: {
            Text("Add Destination")
          }
          .buttonStyle(.borderedProminent)
        }
      })
      .sheet(isPresented: $showAddDestinationSheet, content: {
        AddDestinationView()
      })
      .navigationTitle("My Travel Journal")
      .navigationViewStyle(.stack)
    }
  }
}

struct ContentView_Previews: PreviewProvider {
  static var previews: some View {
    HomeView()
  }
}

// MARK: Custom view modifier
extension View {
  func emptyState<EmptyContent>(_ isEmpty: Bool, emptyContent: @escaping () -> EmptyContent) -> some View where EmptyContent: View {
    modifier(EmptyStateViewModifier(isEmpty: isEmpty, emptyContent: emptyContent))
  }
}

struct EmptyStateViewModifier<EmptyContent>: ViewModifier where EmptyContent: View {
  var isEmpty: Bool
  let emptyContent: () -> EmptyContent

  func body(content: Content) -> some View {
    if isEmpty {
      emptyContent()
    } else {
      content
    }
  }
}
5. ImagePicker.swift
import SwiftUI

struct ImagePicker: UIViewControllerRepresentable {
  @Environment(\.presentationMode) var presentationMode
  @Binding var image: UIImage?

  func makeUIViewController(context: UIViewControllerRepresentableContext<ImagePicker>) -> UIImagePickerController {
    let picker = UIImagePickerController()
    picker.delegate = context.coordinator
    return picker
  }

  func updateUIViewController(_ uiViewController: UIImagePickerController, context: UIViewControllerRepresentableContext<ImagePicker>) {
  }

  func makeCoordinator() -> Coordinator {
    Coordinator(self)
  }

  final class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
    let parent: ImagePicker
    init(_ parent: ImagePicker) {
      self.parent = parent
    }

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
      if let uiImage = info[.originalImage] as? UIImage {
        parent.image = uiImage
      }
      parent.presentationMode.wrappedValue.dismiss()
    }
  }
}
6. DestinationDetailView.swift
import CloudKit
import SwiftUI

struct DestinationDetailView: View {
  @ObservedObject var destination: Destination
  @State private var share: CKShare?
  @State private var showShareSheet = false
  @State private var showEditSheet = false
  private let stack = CoreDataStack.shared

  var body: some View {
    // swiftlint:disable trailing_closure
    List {
      Section {
        VStack(alignment: .leading, spacing: 4) {
          if let imageData = destination.image, let image = UIImage(data: imageData) {
            Image(uiImage: image)
              .resizable()
              .scaledToFit()
          }
          Text(destination.caption)
            .font(.headline)
          Text(destination.details)
            .font(.subheadline)
          Text(destination.createdAt.formatted(date: .abbreviated, time: .shortened))
            .font(.footnote)
            .foregroundColor(.secondary)
            .padding(.bottom, 8)
        }
      }

      Section {
        if let share = share {
          ForEach(share.participants, id: \.self) { participant in
            VStack(alignment: .leading) {
              Text(participant.userIdentity.nameComponents?.formatted(.name(style: .long)) ?? "")
                .font(.headline)
              Text("Acceptance Status: \(string(for: participant.acceptanceStatus))")
                .font(.subheadline)
              Text("Role: \(string(for: participant.role))")
                .font(.subheadline)
              Text("Permissions: \(string(for: participant.permission))")
                .font(.subheadline)
            }
            .padding(.bottom, 8)
          }
        }
      } header: {
        Text("Participants")
      }
    }
    .sheet(isPresented: $showShareSheet, content: {
      if let share = share {
        CloudSharingView(share: share, container: stack.ckContainer, destination: destination)
      }
    })
    .sheet(isPresented: $showEditSheet, content: {
      EditDestinationView(destination: destination)
    })
    .onAppear(perform: {
      self.share = stack.getShare(destination)
    })
    .toolbar {
      ToolbarItem(placement: .navigationBarTrailing) {
        Button {
          showEditSheet.toggle()
        } label: {
          Text("Edit")
        }
        .disabled(!stack.canEdit(object: destination))
      }
      ToolbarItem(placement: .navigationBarTrailing) {
        Button {
          if !stack.isShared(object: destination) {
            Task {
              await createShare(destination)
            }
          }
          showShareSheet = true
        } label: {
          Image(systemName: "square.and.arrow.up")
        }
      }
    }
  }
}

// MARK: Returns CKShare participant permission, methods and properties to share
extension DestinationDetailView {
  private func createShare(_ destination: Destination) async {
    do {
      let (_, share, _) = try await stack.persistentContainer.share([destination], to: nil)
      share[CKShare.SystemFieldKey.title] = destination.caption
      self.share = share
    } catch {
      print("Failed to create share")
    }
  }

  private func string(for permission: CKShare.ParticipantPermission) -> String {
    switch permission {
    case .unknown:
      return "Unknown"
    case .none:
      return "None"
    case .readOnly:
      return "Read-Only"
    case .readWrite:
      return "Read-Write"
    @unknown default:
      fatalError("A new value added to CKShare.Participant.Permission")
    }
  }

  private func string(for role: CKShare.ParticipantRole) -> String {
    switch role {
    case .owner:
      return "Owner"
    case .privateUser:
      return "Private User"
    case .publicUser:
      return "Public User"
    case .unknown:
      return "Unknown"
    @unknown default:
      fatalError("A new value added to CKShare.Participant.Role")
    }
  }

  private func string(for acceptanceStatus: CKShare.ParticipantAcceptanceStatus) -> String {
    switch acceptanceStatus {
    case .accepted:
      return "Accepted"
    case .removed:
      return "Removed"
    case .pending:
      return "Invited"
    case .unknown:
      return "Unknown"
    @unknown default:
      fatalError("A new value added to CKShare.Participant.AcceptanceStatus")
    }
  }

  private var canEdit: Bool {
    stack.canEdit(object: destination)
  }
}
7. EditDestinationView.swift
import SwiftUI

struct EditDestinationView: View {
  let destination: Destination
  private var stack = CoreDataStack.shared
  private var hasInvalidData: Bool {
    return destination.caption.isBlank ||
    destination.details.isBlank ||
    (destination.caption == captionText && destination.details == detailsText)
  }

  @State private var captionText: String = ""
  @State private var detailsText: String = ""
  @Environment(\.presentationMode) var presentationMode
  @Environment(\.managedObjectContext) var managedObjectContext

  init(destination: Destination) {
    self.destination = destination
  }

  var body: some View {
    NavigationView {
      VStack {
        VStack(alignment: .leading) {
          Text("Caption")
            .font(.caption)
            .foregroundColor(.secondary)
          TextField(text: $captionText) {}
            .textFieldStyle(.roundedBorder)
        }
        .padding(.bottom, 8)

        VStack(alignment: .leading) {
          Text("Details")
            .font(.caption)
            .foregroundColor(.secondary)
          TextEditor(text: $detailsText)
        }
      }
      .padding()
      .navigationTitle("Edit Destination")
      .toolbar {
        ToolbarItem(placement: .navigationBarTrailing) {
          Button {
            managedObjectContext.performAndWait {
              destination.caption = captionText
              destination.details = detailsText
              stack.save()
              presentationMode.wrappedValue.dismiss()
            }
          } label: {
            Text("Save")
          }
          .disabled(hasInvalidData)
        }
        ToolbarItem(placement: .navigationBarLeading) {
          Button {
            presentationMode.wrappedValue.dismiss()
          } label: {
            Text("Cancel")
          }
        }
      }
    }
    .onAppear {
      captionText = destination.caption
      detailsText = destination.details
    }
  }
}

// MARK: String
extension String {
  var isBlank: Bool {
    self.trimmingCharacters(in: .whitespaces).isEmpty
  }
}
8. Destination+CoreDataClass.swift
import CoreData

@objc(Destination)
public class Destination: NSManagedObject {
}
9. Destination+CoreDataProperties.swift
import CoreData

// MARK: Fetch request and managed object properties
extension Destination {
  @nonobjc
  public class func fetchRequest() -> NSFetchRequest<Destination> {
    return NSFetchRequest<Destination>(entityName: "Destination")
  }

  @NSManaged public var caption: String
  @NSManaged public var createdAt: Date
  @NSManaged public var details: String
  @NSManaged public var id: UUID
  @NSManaged public var image: Data?
}

// MARK: Identifiable
extension Destination: Identifiable {
}
10. AppMain.swift
import SwiftUI

@main
struct AppMain: App {
  @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
  var body: some Scene {
    WindowGroup {
      HomeView()
        .environment(\.managedObjectContext, CoreDataStack.shared.context)
    }
  }
}
11. AppDelegate.swift
import CloudKit
import SwiftUI

final class AppDelegate: NSObject, UIApplicationDelegate {
  func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
    let sceneConfig = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
    sceneConfig.delegateClass = SceneDelegate.self
    return sceneConfig
  }
}

final class SceneDelegate: NSObject, UIWindowSceneDelegate {
  func windowScene(_ windowScene: UIWindowScene, userDidAcceptCloudKitShareWith cloudKitShareMetadata: CKShare.Metadata) {
    let shareStore = CoreDataStack.shared.sharedPersistentStore
    let persistentContainer = CoreDataStack.shared.persistentContainer
    persistentContainer.acceptShareInvitations(from: [cloudKitShareMetadata], into: shareStore) { _, error in
      if let error = error {
        print("acceptShareInvitation error :\(error)")
      }
    }
  }
}

后记

本篇主要讲述了使用 SwiftUI AppCore DataCloudKit之间的数据共享,感兴趣的给个赞或者关注~~~

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,013评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,205评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 152,370评论 0 342
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,168评论 1 278
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,153评论 5 371
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,954评论 1 283
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,271评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,916评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,382评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,877评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,989评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,624评论 4 322
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,209评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,199评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,418评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,401评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,700评论 2 345

推荐阅读更多精彩内容