Summary: Our very own SeaMammal plugin for iOS written in swift Reviewed By: passy Differential Revision: D15199381 fbshipit-source-id: 10b085c314328ff52ae3f5feef51f70d0ce12f1b
35 lines
775 B
Swift
35 lines
775 B
Swift
//
|
|
// MyFlipperPlugin.swift
|
|
// Tutorial
|
|
//
|
|
// Created by Pritesh Nandgaonkar on 5/3/19.
|
|
// Copyright © 2019 Facebook. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import FlipperKit
|
|
|
|
class SeaMammalsPlugin: NSObject, FlipperPlugin {
|
|
var connection: FlipperConnection? = nil
|
|
let mammals: [MarineMammal]
|
|
|
|
init(_ marineMammals: [MarineMammal]) {
|
|
mammals = marineMammals
|
|
}
|
|
|
|
func identifier() -> String! {
|
|
return "sea-mammals"
|
|
}
|
|
|
|
func didConnect(_ connection: FlipperConnection!) {
|
|
self.connection = connection
|
|
for (index, mammal) in mammals.enumerated() {
|
|
connection.send("newRow", withParams: ["id": index, "title": mammal.name, "url": mammal.image.absoluteString])
|
|
}
|
|
}
|
|
|
|
func didDisconnect() {
|
|
connection = nil;
|
|
}
|
|
}
|