Why is my delegate only passing the First member of the Array?iPhone hide Navigation Bar only on first pageWhy are Objective-C delegates usually given the property assign instead of retain?when & why to use delegates?Passing Arrays/Objects between ViewControllers in SwiftAdding multiple images in a story Core Data iOS 8Parse array seems to store locally to my app sessionHow can I convert byte array to base64 string in swift?Swift Error - Use of undeclared type 'cell' - Collection ViewHow to make root navigation bar transparent, but child navigation bars not?TableView Controller is hiding the dropshadow of swipemenu in swift 4

Can you open the door or die? v2

What does BREAD stand for while drafting?

Why does there seem to be an extreme lack of public trashcans in Taiwan?

If absolute velocity does not exist, how can we say a rocket accelerates in empty space?

How can religions without a hell discourage evil-doing?

Is all-caps blackletter no longer taboo?

How to soundproof the Wood Shop?

ISP is not hashing the password I log in with online. Should I take any action?

Do Veracrypt encrypted volumes have any kind of brute force protection?

When editor does not respond to the request for withdrawal

How can calculate the turn-off time of an LDO?

Does the UK delegate some immigration control to the Republic of Ireland?

Part of my house is inexplicably gone

What publication claimed that Michael Jackson died in a nuclear holocaust?

I am caught when I was about to steal some candies

Why is it bad to use your whole foot in rock climbing

Is it a good security practice to force employees hide their employer to avoid being targeted?

What did the 8086 (and 8088) do upon encountering an illegal instruction?

Is Jesus the last Prophet?

About the paper by Buekenhout, Delandtsheer, Doyen, Kleidman, Liebeck and Saxl

How to represent jealousy in a cute way?

Must I use my personal social media account for work?

Is plausible to have subspecies with & without separate sexes?

Realistic, logical way for men with medieval-era weaponry to compete with much larger and physically stronger foes



Why is my delegate only passing the First member of the Array?


iPhone hide Navigation Bar only on first pageWhy are Objective-C delegates usually given the property assign instead of retain?when & why to use delegates?Passing Arrays/Objects between ViewControllers in SwiftAdding multiple images in a story Core Data iOS 8Parse array seems to store locally to my app sessionHow can I convert byte array to base64 string in swift?Swift Error - Use of undeclared type 'cell' - Collection ViewHow to make root navigation bar transparent, but child navigation bars not?TableView Controller is hiding the dropshadow of swipemenu in swift 4






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have a view controller where a user can add and delete areas, I currently will add multiple members to the array, and then attempt to pass the data back. It will send the first member and the rest get lost.



I've troubleshot how many areas have at each point, and I've pinpointed it to when the data gets passed back into that View, It only has 1 member.



Here is where the array is declared in the first VC:



var areas = [areaProps(x: "New Area", y: "", z: "", a: "", b: "", p1: nil, p2: nil, p3: nil)]


Here is where it is saved back:



func setArray(obj: [areaProps]) 
areas = obj
print("Set Array Sucessfully")
print(areas.count)// contains the actual amount of objects that were created.


override func willMove(toParent parent: UIViewController?)
super.willMove(toParent:parent)
if parent == nil
print("Back Button Pressed")
delegate?.setArray(obj: areaArray)




And when it is passed back here is how, and showing that it only has 1 member here:



 override func prepare(for segue: UIStoryboardSegue, sender: Any?) 
if segue.identifier == "goToMainDetails"
let vc = segue.destination as! addOverview
vc.overview = overview
else if segue.identifier == "goToServiceArea" // this is the segue
let vc = segue.destination as! areaDetails
vc.areaArray = areas
print(" (areas.count) Areas in Array ") // the array contains only 1 object
else





Here is the class of the delegate and where it is initialized:



 var delegate:AreaDelegate?



protocol AreaDelegate
func setArray(obj: [areaProps])



To also clarify what is going on here, the first object in the array will pass over with its edited properties, however and additional object will not pass. For example if i change the title of the 1st area in the second view, it will pass back and forth with that new title.



Here is my AreaProps Class if it helps



 var area : String
var fix : String
var surface : String
var density : String
var pic1 : UIImage?
var pic2 : UIImage?
var pic3 : UIImage?
var notes : String

override init()
area = ""
fix = ""
surface = ""
density = ""
notes = ""
pic1 = nil
pic2 = nil
pic3 = nil

convenience init(x : String, y : String, z : String, a : String, b : String, p1 : UIImage?, p2: UIImage?, p3: UIImage?)

self.init()

let size : CGSize = CGSize(width: 150, height: 150)
area = x
fix = y
surface = z
density = a
notes = b
pic1 = p1
pic1 = pic1?.imageResize(sizeChange: size)
pic2 = p2
pic2 = pic2?.imageResize(sizeChange: size)
pic3 = p3
pic3 = pic3?.imageResize(sizeChange: size)











share|improve this question
























  • Can you post more code? In your current code is not the problem I think.

    – Sean Stayn
    Mar 25 at 1:58











  • What is your delegate? Where do you set it? Its hard to understand the corelation between your objects from these snippets - can you edit your question with entire classess?

    – Losiowaty
    Mar 25 at 1:58











  • Yes what else can i post to clarify>

    – DRaff
    Mar 25 at 2:56











  • @SeanStayn I have updated the post with more information and class declarations-- hopefully that allows you to understand my issue

    – DRaff
    Mar 25 at 3:00











  • @Losiowaty I have added in where i set the delegate and the protocol to support it as wel

    – DRaff
    Mar 25 at 3:01

















0















I have a view controller where a user can add and delete areas, I currently will add multiple members to the array, and then attempt to pass the data back. It will send the first member and the rest get lost.



I've troubleshot how many areas have at each point, and I've pinpointed it to when the data gets passed back into that View, It only has 1 member.



Here is where the array is declared in the first VC:



var areas = [areaProps(x: "New Area", y: "", z: "", a: "", b: "", p1: nil, p2: nil, p3: nil)]


Here is where it is saved back:



func setArray(obj: [areaProps]) 
areas = obj
print("Set Array Sucessfully")
print(areas.count)// contains the actual amount of objects that were created.


override func willMove(toParent parent: UIViewController?)
super.willMove(toParent:parent)
if parent == nil
print("Back Button Pressed")
delegate?.setArray(obj: areaArray)




And when it is passed back here is how, and showing that it only has 1 member here:



 override func prepare(for segue: UIStoryboardSegue, sender: Any?) 
if segue.identifier == "goToMainDetails"
let vc = segue.destination as! addOverview
vc.overview = overview
else if segue.identifier == "goToServiceArea" // this is the segue
let vc = segue.destination as! areaDetails
vc.areaArray = areas
print(" (areas.count) Areas in Array ") // the array contains only 1 object
else





Here is the class of the delegate and where it is initialized:



 var delegate:AreaDelegate?



protocol AreaDelegate
func setArray(obj: [areaProps])



To also clarify what is going on here, the first object in the array will pass over with its edited properties, however and additional object will not pass. For example if i change the title of the 1st area in the second view, it will pass back and forth with that new title.



Here is my AreaProps Class if it helps



 var area : String
var fix : String
var surface : String
var density : String
var pic1 : UIImage?
var pic2 : UIImage?
var pic3 : UIImage?
var notes : String

override init()
area = ""
fix = ""
surface = ""
density = ""
notes = ""
pic1 = nil
pic2 = nil
pic3 = nil

convenience init(x : String, y : String, z : String, a : String, b : String, p1 : UIImage?, p2: UIImage?, p3: UIImage?)

self.init()

let size : CGSize = CGSize(width: 150, height: 150)
area = x
fix = y
surface = z
density = a
notes = b
pic1 = p1
pic1 = pic1?.imageResize(sizeChange: size)
pic2 = p2
pic2 = pic2?.imageResize(sizeChange: size)
pic3 = p3
pic3 = pic3?.imageResize(sizeChange: size)











share|improve this question
























  • Can you post more code? In your current code is not the problem I think.

    – Sean Stayn
    Mar 25 at 1:58











  • What is your delegate? Where do you set it? Its hard to understand the corelation between your objects from these snippets - can you edit your question with entire classess?

    – Losiowaty
    Mar 25 at 1:58











  • Yes what else can i post to clarify>

    – DRaff
    Mar 25 at 2:56











  • @SeanStayn I have updated the post with more information and class declarations-- hopefully that allows you to understand my issue

    – DRaff
    Mar 25 at 3:00











  • @Losiowaty I have added in where i set the delegate and the protocol to support it as wel

    – DRaff
    Mar 25 at 3:01













0












0








0








I have a view controller where a user can add and delete areas, I currently will add multiple members to the array, and then attempt to pass the data back. It will send the first member and the rest get lost.



I've troubleshot how many areas have at each point, and I've pinpointed it to when the data gets passed back into that View, It only has 1 member.



Here is where the array is declared in the first VC:



var areas = [areaProps(x: "New Area", y: "", z: "", a: "", b: "", p1: nil, p2: nil, p3: nil)]


Here is where it is saved back:



func setArray(obj: [areaProps]) 
areas = obj
print("Set Array Sucessfully")
print(areas.count)// contains the actual amount of objects that were created.


override func willMove(toParent parent: UIViewController?)
super.willMove(toParent:parent)
if parent == nil
print("Back Button Pressed")
delegate?.setArray(obj: areaArray)




And when it is passed back here is how, and showing that it only has 1 member here:



 override func prepare(for segue: UIStoryboardSegue, sender: Any?) 
if segue.identifier == "goToMainDetails"
let vc = segue.destination as! addOverview
vc.overview = overview
else if segue.identifier == "goToServiceArea" // this is the segue
let vc = segue.destination as! areaDetails
vc.areaArray = areas
print(" (areas.count) Areas in Array ") // the array contains only 1 object
else





Here is the class of the delegate and where it is initialized:



 var delegate:AreaDelegate?



protocol AreaDelegate
func setArray(obj: [areaProps])



To also clarify what is going on here, the first object in the array will pass over with its edited properties, however and additional object will not pass. For example if i change the title of the 1st area in the second view, it will pass back and forth with that new title.



Here is my AreaProps Class if it helps



 var area : String
var fix : String
var surface : String
var density : String
var pic1 : UIImage?
var pic2 : UIImage?
var pic3 : UIImage?
var notes : String

override init()
area = ""
fix = ""
surface = ""
density = ""
notes = ""
pic1 = nil
pic2 = nil
pic3 = nil

convenience init(x : String, y : String, z : String, a : String, b : String, p1 : UIImage?, p2: UIImage?, p3: UIImage?)

self.init()

let size : CGSize = CGSize(width: 150, height: 150)
area = x
fix = y
surface = z
density = a
notes = b
pic1 = p1
pic1 = pic1?.imageResize(sizeChange: size)
pic2 = p2
pic2 = pic2?.imageResize(sizeChange: size)
pic3 = p3
pic3 = pic3?.imageResize(sizeChange: size)











share|improve this question
















I have a view controller where a user can add and delete areas, I currently will add multiple members to the array, and then attempt to pass the data back. It will send the first member and the rest get lost.



I've troubleshot how many areas have at each point, and I've pinpointed it to when the data gets passed back into that View, It only has 1 member.



Here is where the array is declared in the first VC:



var areas = [areaProps(x: "New Area", y: "", z: "", a: "", b: "", p1: nil, p2: nil, p3: nil)]


Here is where it is saved back:



func setArray(obj: [areaProps]) 
areas = obj
print("Set Array Sucessfully")
print(areas.count)// contains the actual amount of objects that were created.


override func willMove(toParent parent: UIViewController?)
super.willMove(toParent:parent)
if parent == nil
print("Back Button Pressed")
delegate?.setArray(obj: areaArray)




And when it is passed back here is how, and showing that it only has 1 member here:



 override func prepare(for segue: UIStoryboardSegue, sender: Any?) 
if segue.identifier == "goToMainDetails"
let vc = segue.destination as! addOverview
vc.overview = overview
else if segue.identifier == "goToServiceArea" // this is the segue
let vc = segue.destination as! areaDetails
vc.areaArray = areas
print(" (areas.count) Areas in Array ") // the array contains only 1 object
else





Here is the class of the delegate and where it is initialized:



 var delegate:AreaDelegate?



protocol AreaDelegate
func setArray(obj: [areaProps])



To also clarify what is going on here, the first object in the array will pass over with its edited properties, however and additional object will not pass. For example if i change the title of the 1st area in the second view, it will pass back and forth with that new title.



Here is my AreaProps Class if it helps



 var area : String
var fix : String
var surface : String
var density : String
var pic1 : UIImage?
var pic2 : UIImage?
var pic3 : UIImage?
var notes : String

override init()
area = ""
fix = ""
surface = ""
density = ""
notes = ""
pic1 = nil
pic2 = nil
pic3 = nil

convenience init(x : String, y : String, z : String, a : String, b : String, p1 : UIImage?, p2: UIImage?, p3: UIImage?)

self.init()

let size : CGSize = CGSize(width: 150, height: 150)
area = x
fix = y
surface = z
density = a
notes = b
pic1 = p1
pic1 = pic1?.imageResize(sizeChange: size)
pic2 = p2
pic2 = pic2?.imageResize(sizeChange: size)
pic3 = p3
pic3 = pic3?.imageResize(sizeChange: size)








ios swift delegates segue






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 12:08







DRaff

















asked Mar 25 at 0:22









DRaffDRaff

84




84












  • Can you post more code? In your current code is not the problem I think.

    – Sean Stayn
    Mar 25 at 1:58











  • What is your delegate? Where do you set it? Its hard to understand the corelation between your objects from these snippets - can you edit your question with entire classess?

    – Losiowaty
    Mar 25 at 1:58











  • Yes what else can i post to clarify>

    – DRaff
    Mar 25 at 2:56











  • @SeanStayn I have updated the post with more information and class declarations-- hopefully that allows you to understand my issue

    – DRaff
    Mar 25 at 3:00











  • @Losiowaty I have added in where i set the delegate and the protocol to support it as wel

    – DRaff
    Mar 25 at 3:01

















  • Can you post more code? In your current code is not the problem I think.

    – Sean Stayn
    Mar 25 at 1:58











  • What is your delegate? Where do you set it? Its hard to understand the corelation between your objects from these snippets - can you edit your question with entire classess?

    – Losiowaty
    Mar 25 at 1:58











  • Yes what else can i post to clarify>

    – DRaff
    Mar 25 at 2:56











  • @SeanStayn I have updated the post with more information and class declarations-- hopefully that allows you to understand my issue

    – DRaff
    Mar 25 at 3:00











  • @Losiowaty I have added in where i set the delegate and the protocol to support it as wel

    – DRaff
    Mar 25 at 3:01
















Can you post more code? In your current code is not the problem I think.

– Sean Stayn
Mar 25 at 1:58





Can you post more code? In your current code is not the problem I think.

– Sean Stayn
Mar 25 at 1:58













What is your delegate? Where do you set it? Its hard to understand the corelation between your objects from these snippets - can you edit your question with entire classess?

– Losiowaty
Mar 25 at 1:58





What is your delegate? Where do you set it? Its hard to understand the corelation between your objects from these snippets - can you edit your question with entire classess?

– Losiowaty
Mar 25 at 1:58













Yes what else can i post to clarify>

– DRaff
Mar 25 at 2:56





Yes what else can i post to clarify>

– DRaff
Mar 25 at 2:56













@SeanStayn I have updated the post with more information and class declarations-- hopefully that allows you to understand my issue

– DRaff
Mar 25 at 3:00





@SeanStayn I have updated the post with more information and class declarations-- hopefully that allows you to understand my issue

– DRaff
Mar 25 at 3:00













@Losiowaty I have added in where i set the delegate and the protocol to support it as wel

– DRaff
Mar 25 at 3:01





@Losiowaty I have added in where i set the delegate and the protocol to support it as wel

– DRaff
Mar 25 at 3:01












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329884%2fwhy-is-my-delegate-only-passing-the-first-member-of-the-array%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329884%2fwhy-is-my-delegate-only-passing-the-first-member-of-the-array%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript