# Setup Global icon and action use them in different screen in Navigation and Toolbar

**URL:** <https://forums.kodeco.com/t/setup-global-icon-and-action-use-them-in-different-screen-in-navigation-and-toolbar/16299>\
**Category:** iOS\
**Created:** [June 22, 2016, 5:17am UTC](https://forums.kodeco.com/t/setup-global-icon-and-action-use-them-in-different-screen-in-navigation-and-toolbar/16299 "2016-06-22T05:17:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhoblik](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jhoblik/32/35033_2.png) [@jhoblik](https://forums.kodeco.com/u/jhoblik)\
**Post date:** [June 22, 2016, 5:17am UTC](https://forums.kodeco.com/t/setup-global-icon-and-action-use-them-in-different-screen-in-navigation-and-toolbar/16299/1 "2016-06-22T05:17:34Z")

</div>

**I would like to know if you see any architectural pitfall of this approach.**  
1/I don’t want to create navigation and toolbar buttons by dragging on storyboard.  
2/Using navigation controller to have Navigation bar and tool bar on every View  
3/I define butons and action in global appConst.swift and not to force to do it in every ViewController  
4/I could use same icon in different ViewControllers and not worry about consistency  
5/Make view controller clean of generating buttons  
6/I didn’t specify target at creation of button, but when i am using in actual viewcontroller

**1/Global file for constants appConst.swift**  
_let workCenterIcon = “WorkCenter.png”_  
_let workOrderIcon = “WorkOrder.png”_  
let newWrkCtrAction = “newWrkCtrAction”  
let newWrkOrdAction = “newWrkOrdAction”  
//New work center action  
let newWkCtrBtn = UIBarButtonItem(image: UIImage(named: workCenterIcon), style: UIBarButtonItemStyle.Plain, target: nil, action: Selector(newWrkCtrAction ))  
//New Work order action  
let newWkOrdBtn = UIBarButtonItem(image: UIImage(named: workOrderIcon), style: UIBarButtonItemStyle.Plain, target: nil, action: Selector(newWrkOrdAction))  
let spaceBtn = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action:nil )

**2/In any viewController I could use this globally design and maintain icons**  
override func viewDidLoad() {  
super.viewDidLoad()  
//TOOL BAR\*\*\*\*  
//Setup Tool bar buttons  
newWkCtrBtn.target = self  
newWkOrdBtn.target = self  
self.toolbarItems = [spaceBtn,newWkCtrBtn,spaceBtn,newWkOrdBtn,spaceBtn]  
…

func newWrkCtrAction()\_  
{  
print(“tapNewWorkCenterAction”)  
}

```
func newWrkOrdAction()_
{
    print("tapNewOrderAction")_
}

```
