Added custom swift plugin
Summary: Our very own SeaMammal plugin for iOS written in swift Reviewed By: passy Differential Revision: D15199381 fbshipit-source-id: 10b085c314328ff52ae3f5feef51f70d0ce12f1b
This commit is contained in:
committed by
Facebook Github Bot
parent
a8e7f0e028
commit
b1be6400b8
34
iOS/Tutorial/Tutorial/SeaMammalsPlugin.swift
Normal file
34
iOS/Tutorial/Tutorial/SeaMammalsPlugin.swift
Normal file
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user