Swift: Change the tabBar icon from appDelegate - swift

I would like to change an icon of my tabbar from the appDelegate.
I will explain why I want to do that.
From my website I send data by push to my application, so in the appdelegate I recieve the data in the function didReceiveRemoteNotification, with these data I create a local notification manually. I would also like to be able to modify the icon of my TabBar to show that there is a new notification.
So how to change the icon of the tabbar from the app delegate?
Here is a photo of my app, the green circle is the part that means "New notification"
My App images
Here my code in appdelegate:
func application(_ application: UIApplication, didReceiveRemoteNotification data: [AnyHashable: Any]) {
if let data = data as? NSDictionary {
print("Title: \(data)")
LocalNotification.createLocalNotificationWithIntervals(identifier: "Push",
title: data["title"] as! String,
body: data["body"] as! String,
intervals: 1) { error in
guard error == nil else {
print("Error: \(error!.localizedDescription)")
return
}
print("Successfully execute notification")
}
}
}
I user a tabor controller:
class FittoTabBarController: UITabBarController {
let kImageNoLabelInset: CGFloat = 6.0
var selectedTab: FittoTabBar.Tabs = .pods {
didSet {
selectedIndex = selectedTab.rawValue
}
}
override func viewDidLoad() {
super.viewDidLoad()
selectedTab = .pods
removeItemsTitles()
}
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
guard let selectedItemIndex = tabBar.items?.index(of: item),
let selectedTab = FittoTabBar.Tabs(rawValue: selectedItemIndex) else {
return
}
self.selectedTab = selectedTab
}
private func removeItemsTitles() {
if let items = self.tabBar.items {
for item in items {
item.title = ""
item.imageInsets = UIEdgeInsets(top: kImageNoLabelInset, left: 0.0, bottom: -kImageNoLabelInset, right: 0.0)
}
}
}
The input of my application is on the tabbar controller

With the code provided above, You need to follow these steps to make it working.
In your FittoTabBarController add these methods.
func setBadge(_ value: String?) {
_ = self.viewControllers![2].tabBarItem.badgeValue = value
}
func getBadge() -> String? {
return self.viewControllers![2].tabBarItem.badgeValue
}
func resetBadge() {
self.viewControllers![2].tabBarItem.badgeValue = nil
}
In your appDelegate, get the rootViewController of your window, on receiving notification
func application(_ application: UIApplication, didReceiveRemoteNotification data: [AnyHashable: Any]) {
if let data = data as? NSDictionary {
print("Title: \(data)")
let myTabBarController = self.window?.rootViewController as! FittoTabBarController
var newBadgeCount = "1"
if let currentBadgeCount = myTabBarController.getBadge() {
// Convert to int
var intValOfCurrentBadge = Int(currentBadgeCount)!
// Increaset it by one.
intValOfCurrentBadge = intValOfCurrentBadge + 1
// Convert back to string.
newBadgeCount = "\(intValOfCurrentBadge)"
}
// Set your badge value here.
myTabBarController.setBadge(newBadgeCount)
// ADD YOUR EXISTING CODE HERE
}
}
when user clicks on the 3rd tab, just call the resetBadge() method to remove the badge count.
Hope it helps.

Related

How to implement handleUserActivity in WatchOS in SwiftUI?

I've passed to my complicationDescriptors a userInfo dictionary that includes the names of my complications so I can be notified of which complication the user tapped on and launch them to that View. I'm using the new #App and #WKExtensionDelegateAdaptor for other reasons, so I have access to handleUserActivity in my extensionDelegate and can unpack the source of the complication tap, but how do I launch them to a specific view in SwiftUI? handleUserActivity seems to be set up to work with WKInterfaceControllers?
class ExtensionDelegate: NSObject, WKExtensionDelegate {
let defaults = UserDefaults.standard
func applicationDidFinishLaunching() {
//print("ApplicationDidFinishLanching called")
scheduleNextReload()
}
func applicationWillResignActive() {
//print("applicationWillResignActive called")
}
func handleUserActivity(_ userInfo: [AnyHashable : Any]?) {
if let complication = userInfo?[TrackerConstants.complicationUserTappedKey] as? String {
if complication == TrackerConstants.recoveryDescriptorKey {
//What now?
} else if complication == TrackerConstants.exertionDescriptorKey {
//What now?
}
}
}
I managed to update my view according to the tapped complication userInfo by using notifications, inspired by this answer.
First declare a notification name:
extension Notification.Name {
static let complicationTapped = Notification.Name("complicationTapped")
}
In your ExtensionDelegate:
func handleUserActivity(_ userInfo: [AnyHashable : Any]?) {
if let complication = userInfo?[TrackerConstants.complicationUserTappedKey] as? String {
NotificationCenter.default.post(
name: Notification.Name.complicationTapped,
object: complication
)
}
}
Finally in your view:
struct ContentView: View {
#State private var activeComplication: String? = nil
var body: some View {
NavigationView { // or TabView, etc
// Your content with NavigationLinks
}
.onReceive(NotificationCenter.default.publisher(
for: Notification.Name.complicationTapped
)) { output in
self.activeComplication = output.object as? String
}
}
}
For more information on how to activate a view from here, see Programmatic navigation in SwiftUI

NSDocument Never Saves Document

Life was fairly easy when I first test-developed a text-based application with NSDocument. Now, I have a lot more complicated document-based desktop application with several custom models other than a string with NSTextView. My subclass of NSDocument is the following.
import Cocoa
class Document: NSDocument {
// MARK: - Variables
var image = NSImage()
var myPasteModels = [PasteModel]()
var myPanModel: PanModel?
var myWinModel: WindowModel?
// MARK: - Initialization
override init() {
super.init()
}
// MARK: - Auto saving
override class var autosavesInPlace: Bool {
return false
}
override func data(ofType typeName: String) throws -> Data {
if let viewController = windowControllers[0].contentViewController as? MainViewController {
if viewController.imageModels.count > 0 {
viewController.saveSubViewPositions()
if let window = viewController.view.window {
var pasteModels = [PasteModel]()
for i in 0..<viewController.imageModels.count {
let imageModel = viewController.imageModels[i]
...
...
}
NSKeyedArchiver.setClassName("ColorModel", for: ColorModel.self)
NSKeyedArchiver.setClassName("TextModel", for: TextModel.self)
NSKeyedArchiver.setClassName("ShapeModel", for: ShapeModel.self)
NSKeyedArchiver.setClassName("ShadeModel", for: ShadeModel.self)
NSKeyedArchiver.setClassName("LineModel", for: LineModel.self)
NSKeyedArchiver.setClassName("GradientModel", for: GradientModel.self)
NSKeyedArchiver.setClassName("ArrowModel", for: ArrowModel.self)
NSKeyedArchiver.setClassName("PasteModel", for: PasteModel.self)
NSKeyedArchiver.setClassName("PanModel", for: PanModel.self)
NSKeyedArchiver.setClassName("WindowModel", for: WindowModel.self)
let panModel = PanModel(frameWidth: viewController.panView.frame.size.width, frameHeight: viewController.panView.frame.size.height)
let winModel = WindowModel(width: window.frame.width, height: window.frame.height)
let dict = ["PasteModel": pasteModels, "PanModel": panModel, "WindowModel": winModel] as [String : Any]
do {
let modelData = try NSKeyedArchiver.archivedData(withRootObject: dict, requiringSecureCoding: false)
return modelData
} catch let error as NSError {
Swift.print("\(error)")
}
}
}
}
throw NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil)
}
override func save(withDelegate delegate: Any?, didSave didSaveSelector: Selector?, contextInfo: UnsafeMutableRawPointer?) {
if let _ = fileURL {
Swift.print("Saved!!!")
} else {
Swift.print("Not saved yet...")
NSApp.sendAction(#selector(NSDocument.saveAs(_:)), to: nil, from: self)
}
}
override func prepareSavePanel(_ savePanel: NSSavePanel) -> Bool {
savePanel.allowedFileTypes = ["fss"]
savePanel.allowsOtherFileTypes = true
savePanel.isExtensionHidden = false
return true
}
}
The problem that I have is that the application never saves a document if I choose Save As under File (or press Command + Shift + S). If I choose Save As, the application goes beep and dismiss the command selection. It does enter the prepareSavePanel method if I set a break point there. So what can I do to go any further? Thanks.

Why is my UIViewController not showing up in my popup card?

I wanted to create a pop up for one of my UIViewController and found this repo on GitHub.
It is working fine with my InfoViewController which only has 4 UILabels (I think this might be the problem that it is not showing up when you use reusable cells)
But somehow it is not working with my StructureNavigationListViewController and I do not know why.
I call the didTapCategory method in my MainViewController where the StructureNavigationController should pop up but I only see the dimming view (which is weird cause the tap recognizer and pan gestures are working fine but no content is showing up)
In my MainViewController I set up the popup like before:
#IBAction func didTapCategory(_ sender: UIBarButtonItem) {
let popupContent = StructureNavigationListViewController.create()
let cardpopUp = SBCardPopupViewController(contentViewController: popupContent)
cardpopUp.show(onViewController: self)
}
In my StructureNavigationListViewController I set up the table view and the pop up:
public var popupViewController: SBCardPopupViewController?
public var allowsTapToDismissPopupCard: Bool = true
public var allowsSwipeToDismissPopupCard: Bool = true
static func create() -> UIViewController {
let sb = UIStoryboard(name: "Main", bundle: nil)
let vc = sb.instantiateViewController(withIdentifier: "StructureNavigationListViewController") as! StructureNavigationListViewController
return vc
}
#IBOutlet var tableView: UITableView!
var structures = Variable<[Structure]>([])
public var treeSource: StructureTreeSource?
let disposeBag = DisposeBag()
var depthDictionary : [String : Int] = [:]
public override func viewDidLoad() {
structures.asObservable()
.bind(to:tableView.rx.items) {(tableView, row, structure) in
let cell = tableView.dequeueReusableCell(withIdentifier: "StructureNavigationCell", for: IndexPath(row: row, section: 0)) as! StructureNavigationCell
cell.structureLabel.text = structure.name
cell.spacingViewWidthConstraint.constant = 20 * CGFloat(self.depthDictionary[structure.id]!)
return cell
}.disposed(by:disposeBag)
_ = tableView.rx.modelSelected(Structure.self).subscribe(onNext: { structure in
let storyBoard = UIStoryboard(name:"Main", bundle:nil)
let plansViewCtrl = storyBoard.instantiateViewController(withIdentifier: "PlansViewController2") as! PlansViewController2
self.treeSource?.select(structure)
plansViewCtrl.treeSource = self.treeSource
plansViewCtrl.navigationItem.title = structure.name
self.show(plansViewCtrl, sender: self)
if let mainVC = self.parent as? ProjectOverViewTabController2 {
mainVC.addChildView(viewController: plansViewCtrl, in: mainVC.scrollView)
}
})
showList()
}
func showList() {
if treeSource == nil {
treeSource = StructureTreeSource(projectId:GlobalState.selectedProjectId!)
}
//The following piece of code achieves the correct order of structures and their substructures.
//It is extremely bad designed and rather expensive with lots of structures and should
//therefore be refactored!
if let strctrs = getStructures() {
var sortedStructures : [Structure] = []
while(sortedStructures.count != strctrs.count) {
for strct in strctrs {
if let _ = sortedStructures.index(of: strct) {
continue
} else {
depthDictionary[strct.id] = getDepthOfNode(structure: strct, depth: 1)
if let structures = getStructures() {
if let parent = structures.first(where: {$0.id == strct.parentId}) {
if let index = sortedStructures.index(of: parent) {
sortedStructures.insert(strct, at: index+1)
}
} else {
sortedStructures.insert(strct, at: 0)
}
}
}
}
}
structures.value = sortedStructures
tableView.reloadData()
}
}
func getDepthOfNode(structure: Structure, depth: Int) -> Int {
if(structure.parentId == nil || structure.parentId == "") {
return depth
} else {
if let structures = getStructures() {
if let parent = structures.first(where: {$0.id == structure.parentId}) {
return getDepthOfNode(structure: parent, depth: depth + 1)
}
}
}
return -1
}
private func getStructures() -> Results<Structure>? {
do {
if let projectId = GlobalState.selectedProjectId {
return try Structure.db.by(projectId: projectId)
}
} catch { Log.db.error(error: error) }
return nil
}
}
Lot of code here. Sorry..
Is it because I call the create() method after the viewDidLoad() dequeues the cells?
It's hard to tell what is the problem, since you left no information about where didTapCategory is supposed to be called, but maybe it has something to do with your modelSelected subscription being prematurely released?
Edit:
As posted here: https://stackoverflow.com/a/28896452/11851832 if your custom cell is built with Interface Builder then you should register the Nib, not the class:
tableView.registerNib(UINib(nibName: "CustomCell", bundle: nil), forCellReuseIdentifier: "CustomCellIdentifier")

MLMediaLibrary - Displaying the Photo Library -Swift Code Wrong - macOS

Trying to show photos from the Photo Library. The Apple Sample Code below does not work properly. It doesn't wait for the notifications but tries to launch the collection view which crashes at Number of Items in Section because there is no photo data to show.
Thanks for any help from you Swift guru's out there!
/*
Copyright (C) 2016 Apple Inc. All Rights Reserved.
See LICENSE.txt for this sample’s licensing information
Abstract:
The `ViewController` class is a subclass to NSViewController responsible for managing the app's content.
*/
import Cocoa
import MediaLibrary
class IconViewBox : NSBox {
override func hitTest(_ aPoint: NSPoint) -> NSView? {
// Don't allow any mouse clicks for subviews in this NSBox.
return nil
}
}
// MARK: -
class ViewController: NSViewController, NSCollectionViewDelegate {
// MARK: - Types
// Keys describing the dictionary for each photo loaded.
private struct ItemKeys {
static let imageKey = "icon"
static let nameKey = "name"
}
// MLMediaLibrary property values for KVO.
private struct MLMediaLibraryPropertyKeys {
static let mediaSourcesKey = "mediaSources"
static let rootMediaGroupKey = "rootMediaGroup"
static let mediaObjectsKey = "mediaObjects"
static let contentTypeKey = "contentType"
}
// MARK: - Properties
/**
The KVO contexts for `MLMediaLibrary`.
This provides a stable address to use as the `context` parameter for KVO observation methods.
*/
private var mediaSourcesContext = 1
private var rootMediaGroupContext = 2
private var mediaObjectsContext = 3
private var photoSize = CGSize(width: 168, height: 145)
// Contains an array of dictionaries describing each photo (refer to ItemKeys for key/values).
#IBOutlet weak var arrayController: NSArrayController!
#IBOutlet weak var collectionView: NSCollectionView!
#IBOutlet private weak var noPhotosLabel: NSTextField!
#IBOutlet private weak var activityIndicator: NSProgressIndicator!
// MLMediaLibrary instances for loading the photos.
private var mediaLibrary: MLMediaLibrary!
private var mediaSource: MLMediaSource!
private var rootMediaGroup: MLMediaGroup!
// MARK: - View Controller Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
print ("VDL1...................")
// Start progress indicator in case fetching the photos from the photo library takes time.
self.activityIndicator.isHidden = false
self.activityIndicator.startAnimation(self)
self.collectionView.minItemSize = self.photoSize
self.collectionView.maxItemSize = self.photoSize
self.arrayController.setSelectionIndex(-1) // No selection to start out with.
// Setup the media library to load only photos, don't include other source types.
let options: [String : AnyObject] =
[MLMediaLoadSourceTypesKey: MLMediaSourceType.image.rawValue as AnyObject,
MLMediaLoadIncludeSourcesKey: [MLMediaSourcePhotosIdentifier, MLMediaSourceiPhotoIdentifier] as AnyObject]
// Create our media library instance to get our photo.
mediaLibrary = MLMediaLibrary(options: options)
// We want to be called when media sources come in that's available (via observeValueForKeyPath).
self.mediaLibrary.addObserver(self,
forKeyPath: MLMediaLibraryPropertyKeys.mediaSourcesKey,
options: NSKeyValueObservingOptions.new,
context: &mediaSourcesContext)
if (self.mediaLibrary.mediaSources != nil) {
print ("VDL2...................")
} // Reference returns nil but starts the asynchronous loading.
}
deinit {
// Make sure to remove us as an observer before "mediaLibrary" is released.
self.mediaLibrary.removeObserver(self, forKeyPath: MLMediaLibraryPropertyKeys.mediaSourcesKey, context:&mediaSourcesContext)
}
// MARK: - NSCollectionViewDataSource
func numberOfSectionsInCollectionView(_ collectionView: NSCollectionView) -> Int {
return 1
}
func collectionView(_ collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int {
let photos = self.arrayController.arrangedObjects as! NSArray
return photos.count
}
func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAtIndexPath indexPath: IndexPath) -> NSCollectionViewItem {
let item = collectionView.makeItem(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "IconItem"), for:indexPath)
let photos = self.arrayController.arrangedObjects as! NSArray
let iconInfo = photos[(indexPath as NSIndexPath).item]
item.representedObject = iconInfo
return item
}
// MARK: - NSCollectionViewDelegate
func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set<IndexPath>) {
if let itemIndexPath = indexPaths.first {
let photos = self.arrayController.arrangedObjects as! NSArray
let itemDict = photos[((itemIndexPath as NSIndexPath).item)] as! NSDictionary
if let itemTitle = itemDict[ItemKeys.nameKey] as? String {
if (itemTitle.characters.count > 0) {
print("selected photo: '\(itemTitle)'")
}
else {
print("selected photo: <no title>")
}
}
}
}
// MARK: - Utilities
/// Helps to make sure the media object is the photo format we want.
private func isValidImage(_ mediaObject: MLMediaObject) -> Bool {
var isValidImage = false
let attrs = mediaObject.attributes
let contentTypeStr = attrs[MLMediaLibraryPropertyKeys.contentTypeKey] as! String
// We only want photos, not movies or older PICT formats (PICT image files are not supported in a sandboxed environment).
if ((contentTypeStr != kUTTypePICT as String) && (contentTypeStr != kUTTypeQuickTimeMovie as String))
{
isValidImage = true
}
return isValidImage
}
/// Obtains the title of the MLMediaObject (either the meta name or the last component of the URL).
func imageTitle(_ fromMediaObject: MLMediaObject) -> String {
guard let title = fromMediaObject.attributes["name"] else {
return fromMediaObject.url!.lastPathComponent
}
return title as! String
}
// MARK: - Photo Loading
/// Observer for all key paths returned from the MLMediaLibrary.
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
print ("Observe1...................")
if (keyPath == MLMediaLibraryPropertyKeys.mediaSourcesKey && context == &mediaSourcesContext && object! is MLMediaLibrary) {
// The media sources have loaded, we can access the its root media.
if let mediaSource = self.mediaLibrary.mediaSources?[MLMediaSourcePhotosIdentifier] {
self.mediaSource = mediaSource
}
else if let mediaSource = self.mediaLibrary.mediaSources?[MLMediaSourceiPhotoIdentifier] {
self.mediaSource = mediaSource
}
else {
print ("Observe2...................")
// Can't find any media sources.
self.noPhotosLabel.isHidden = false
// Stop progress indicator.
self.activityIndicator.isHidden = true
self.activityIndicator.stopAnimation(self)
return // No photos found.
}
// Media Library is loaded now, we can access mediaSource for photos
self.mediaSource.addObserver(self,
forKeyPath: MLMediaLibraryPropertyKeys.rootMediaGroupKey,
options: NSKeyValueObservingOptions.new,
context: &rootMediaGroupContext)
// Obtain the media grouping (reference returns nil but starts asynchronous loading).
if (self.mediaSource.rootMediaGroup != nil) {}
}
else if (keyPath == MLMediaLibraryPropertyKeys.rootMediaGroupKey && context == &rootMediaGroupContext && object! is MLMediaSource) {
print ("Observe3...................")
// The root media group is loaded, we can access the media objects.
// Done observing for media groups.
self.mediaSource.removeObserver(self, forKeyPath: MLMediaLibraryPropertyKeys.rootMediaGroupKey, context:&rootMediaGroupContext)
self.rootMediaGroup = self.mediaSource.rootMediaGroup
self.rootMediaGroup.addObserver(self,
forKeyPath: MLMediaLibraryPropertyKeys.mediaObjectsKey,
options: NSKeyValueObservingOptions.new,
context: &mediaObjectsContext)
// Obtain the all the photos, (reference returns nil but starts asynchronous loading).
if (self.rootMediaGroup.mediaObjects != nil) {}
}
else if (keyPath == MLMediaLibraryPropertyKeys.mediaObjectsKey && context == &mediaObjectsContext && object! is MLMediaGroup) {
print ("Observe4...................")
// The media objects are loaded, we can now finally access each photo.
// Done observing for media objects that group.
self.rootMediaGroup.removeObserver(self, forKeyPath: MLMediaLibraryPropertyKeys.mediaObjectsKey, context:&mediaObjectsContext)
// Stop progress indicator since we know if we have photos (or not).
self.activityIndicator.isHidden = true
self.activityIndicator.stopAnimation(self)
let mediaObjects = self.rootMediaGroup.mediaObjects
if (mediaObjects != nil && mediaObjects!.count > 0) {
print ("Observe5...................")
// Add photos to the array, to be used in our NSCollectionView.
for mediaObject in mediaObjects! {
if (self.isValidImage(mediaObject)) { // Make sure the media object is a photo.
let title = self.imageTitle(mediaObject)
if let image = NSImage.init(contentsOf: mediaObject.thumbnailURL!) {
let iconItem : Dictionary = [ItemKeys.imageKey: image, ItemKeys.nameKey: title] as [String : Any]
self.arrayController.addObject(iconItem)
}
}
}
self.collectionView.reloadData()
}
else {
// No photos available.
self.noPhotosLabel.isHidden = false
}
self.rootMediaGroup = nil // We are done with this.
}
else {
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
}
}
}
NSCollectionViewDataSource delegate is missing
class ViewController: NSViewController, NSCollectionViewDelegate, NSCollectionViewDataSource
Next you need to fix these methods: 'numberOfSectionsInCollectionView' has been renamed to 'numberOfSections(in:)' 'collectionView(:itemForRepresentedObjectAtIndexPath:)' has been renamed to 'collectionView(:itemForRepresentedObjectAt:)'

Segue causes model data to disappear

I am trying to pass data from my model in my file, CalculatorBrain, to a ViewController through a segue. The var that I am trying to pass is designated as a PropertyList as shown below:
var program: PropertyList { // guaranteed to be PropertyList
get {
return opStack.map { $0.description }
}
set {
if let opSymbols = newValue as? Array<String> {
var newOpStack = [Op]()
for opSymbol in opSymbols {
if let op = knownOps[opSymbol] {
newOpStack.append(op)
} else if let operand = NSNumberFormatter().numberFromString(opSymbol)?.doubleValue {
newOpStack.append(.Operand(operand))
}
}
opStack = newOpStack
}
}
}
This is a multiple MVC project, and the override segue function is in a ViewController called "CalculatorViewController." The function tries to pass the data from the model to the ViewController known as "GraphingViewController" like this:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
var destination: UIViewController? = segue.destinationViewController
if let navCon = destination as? UINavigationController {
destination = navCon.visibleViewController
}
if let gvc = destination as? GraphingViewController {
gvc.program = brain.program
}
}
I set-up the variable program in my GraphingViewController as follows:
var program: AnyObject?
When I press the button that calls the segue, it does fire. What happens is that the data in brain.program gets copied into gvc.program. However, it is then LOST to the model. I don't know why this happens. When I print the program out from the controller in the segue, I do see the program as it should be shown. However, when I print it anywhere after the segue, it has disappeared.
Why would data, after the override segue function is called, be removed?
EDIT: This is the delegate function in the GraphingViewController. When I print out brain.program from here, it doesn't print out the full opStack.
func graphForGraphView(xAxisValue: CGFloat, sender: GraphView) -> CGPoint? {
print("BRAIN PROGRAM 2: \(brain.program)")
brain.variableValues[brain.variableM] = 40.0
if let yValue = brain.returnEvaluate() {
print(yValue)
print("The returned value is: \(yValue)")
let point = CGPoint(x: 40.0, y: CGFloat(yValue))
if !point.x.isNormal || !point.y.isNormal {
return nil
} else {
return point
}
}
return nil
}