issue in calling a function that takes an array of objects and returns an array of objects












-4














I am learning swift and I am trying to call a function that takes an array of object type notificationManager and returns an array of the same object type, here is my function:



func groupNotifs(orignalNotifs: [notificationManager]) -> [notificationManager] {

var newItems: [notificationManager] =
//do things
return newItems
}
}


the issue is when I try to call this function somewhere else by this code :



var groupedNtf: [notificationManager] = 
groupedNtf = self.groupNotifs(orignalNotifs: completions)
completion(groupedNtf)


I receive this error :




Instance member 'groupNotifs' cannot be used on type 'notificationManager'











share|improve this question
























  • First, you declared groupedNtf with notificationManager is wrong, it should be var groupedNtf: [NotificationManager] = and in groupNotifs function parameter type is the array of notificationManager it obvious take the array as a parameter and you're returning also the array of notificationManager? can you please explain what you want ?
    – Abhishek Jadhav
    yesterday










  • You can avoid a lot of confusion if you conform to the naming convention that class names start with a capital letter and variable and function names start with a lowercase letter.
    – vadian
    yesterday












  • What is self ? and notificationManager.Notifcounts
    – Carpsen90
    yesterday










  • the class name is notificationManager not NotificationManager, the function takes an array of notificationManager and it filters it in order to get the unique elements, so naturally the function will return an array of notificationManager as well
    – raddaoui
    yesterday






  • 1




    There are many, many issues in the code. You can fix this particular error if you declare the function as static: static func groupNotifs(... but you will get a lot of other errors about a missing return value, missing conformance to Equatable and Hashable etc.
    – vadian
    23 hours ago


















-4














I am learning swift and I am trying to call a function that takes an array of object type notificationManager and returns an array of the same object type, here is my function:



func groupNotifs(orignalNotifs: [notificationManager]) -> [notificationManager] {

var newItems: [notificationManager] =
//do things
return newItems
}
}


the issue is when I try to call this function somewhere else by this code :



var groupedNtf: [notificationManager] = 
groupedNtf = self.groupNotifs(orignalNotifs: completions)
completion(groupedNtf)


I receive this error :




Instance member 'groupNotifs' cannot be used on type 'notificationManager'











share|improve this question
























  • First, you declared groupedNtf with notificationManager is wrong, it should be var groupedNtf: [NotificationManager] = and in groupNotifs function parameter type is the array of notificationManager it obvious take the array as a parameter and you're returning also the array of notificationManager? can you please explain what you want ?
    – Abhishek Jadhav
    yesterday










  • You can avoid a lot of confusion if you conform to the naming convention that class names start with a capital letter and variable and function names start with a lowercase letter.
    – vadian
    yesterday












  • What is self ? and notificationManager.Notifcounts
    – Carpsen90
    yesterday










  • the class name is notificationManager not NotificationManager, the function takes an array of notificationManager and it filters it in order to get the unique elements, so naturally the function will return an array of notificationManager as well
    – raddaoui
    yesterday






  • 1




    There are many, many issues in the code. You can fix this particular error if you declare the function as static: static func groupNotifs(... but you will get a lot of other errors about a missing return value, missing conformance to Equatable and Hashable etc.
    – vadian
    23 hours ago
















-4












-4








-4


0





I am learning swift and I am trying to call a function that takes an array of object type notificationManager and returns an array of the same object type, here is my function:



func groupNotifs(orignalNotifs: [notificationManager]) -> [notificationManager] {

var newItems: [notificationManager] =
//do things
return newItems
}
}


the issue is when I try to call this function somewhere else by this code :



var groupedNtf: [notificationManager] = 
groupedNtf = self.groupNotifs(orignalNotifs: completions)
completion(groupedNtf)


I receive this error :




Instance member 'groupNotifs' cannot be used on type 'notificationManager'











share|improve this question















I am learning swift and I am trying to call a function that takes an array of object type notificationManager and returns an array of the same object type, here is my function:



func groupNotifs(orignalNotifs: [notificationManager]) -> [notificationManager] {

var newItems: [notificationManager] =
//do things
return newItems
}
}


the issue is when I try to call this function somewhere else by this code :



var groupedNtf: [notificationManager] = 
groupedNtf = self.groupNotifs(orignalNotifs: completions)
completion(groupedNtf)


I receive this error :




Instance member 'groupNotifs' cannot be used on type 'notificationManager'








ios arrays swift






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 23 hours ago

























asked yesterday









raddaoui

329




329












  • First, you declared groupedNtf with notificationManager is wrong, it should be var groupedNtf: [NotificationManager] = and in groupNotifs function parameter type is the array of notificationManager it obvious take the array as a parameter and you're returning also the array of notificationManager? can you please explain what you want ?
    – Abhishek Jadhav
    yesterday










  • You can avoid a lot of confusion if you conform to the naming convention that class names start with a capital letter and variable and function names start with a lowercase letter.
    – vadian
    yesterday












  • What is self ? and notificationManager.Notifcounts
    – Carpsen90
    yesterday










  • the class name is notificationManager not NotificationManager, the function takes an array of notificationManager and it filters it in order to get the unique elements, so naturally the function will return an array of notificationManager as well
    – raddaoui
    yesterday






  • 1




    There are many, many issues in the code. You can fix this particular error if you declare the function as static: static func groupNotifs(... but you will get a lot of other errors about a missing return value, missing conformance to Equatable and Hashable etc.
    – vadian
    23 hours ago




















  • First, you declared groupedNtf with notificationManager is wrong, it should be var groupedNtf: [NotificationManager] = and in groupNotifs function parameter type is the array of notificationManager it obvious take the array as a parameter and you're returning also the array of notificationManager? can you please explain what you want ?
    – Abhishek Jadhav
    yesterday










  • You can avoid a lot of confusion if you conform to the naming convention that class names start with a capital letter and variable and function names start with a lowercase letter.
    – vadian
    yesterday












  • What is self ? and notificationManager.Notifcounts
    – Carpsen90
    yesterday










  • the class name is notificationManager not NotificationManager, the function takes an array of notificationManager and it filters it in order to get the unique elements, so naturally the function will return an array of notificationManager as well
    – raddaoui
    yesterday






  • 1




    There are many, many issues in the code. You can fix this particular error if you declare the function as static: static func groupNotifs(... but you will get a lot of other errors about a missing return value, missing conformance to Equatable and Hashable etc.
    – vadian
    23 hours ago


















First, you declared groupedNtf with notificationManager is wrong, it should be var groupedNtf: [NotificationManager] = and in groupNotifs function parameter type is the array of notificationManager it obvious take the array as a parameter and you're returning also the array of notificationManager? can you please explain what you want ?
– Abhishek Jadhav
yesterday




First, you declared groupedNtf with notificationManager is wrong, it should be var groupedNtf: [NotificationManager] = and in groupNotifs function parameter type is the array of notificationManager it obvious take the array as a parameter and you're returning also the array of notificationManager? can you please explain what you want ?
– Abhishek Jadhav
yesterday












You can avoid a lot of confusion if you conform to the naming convention that class names start with a capital letter and variable and function names start with a lowercase letter.
– vadian
yesterday






You can avoid a lot of confusion if you conform to the naming convention that class names start with a capital letter and variable and function names start with a lowercase letter.
– vadian
yesterday














What is self ? and notificationManager.Notifcounts
– Carpsen90
yesterday




What is self ? and notificationManager.Notifcounts
– Carpsen90
yesterday












the class name is notificationManager not NotificationManager, the function takes an array of notificationManager and it filters it in order to get the unique elements, so naturally the function will return an array of notificationManager as well
– raddaoui
yesterday




the class name is notificationManager not NotificationManager, the function takes an array of notificationManager and it filters it in order to get the unique elements, so naturally the function will return an array of notificationManager as well
– raddaoui
yesterday




1




1




There are many, many issues in the code. You can fix this particular error if you declare the function as static: static func groupNotifs(... but you will get a lot of other errors about a missing return value, missing conformance to Equatable and Hashable etc.
– vadian
23 hours ago






There are many, many issues in the code. You can fix this particular error if you declare the function as static: static func groupNotifs(... but you will get a lot of other errors about a missing return value, missing conformance to Equatable and Hashable etc.
– vadian
23 hours ago



















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%2f53943262%2fissue-in-calling-a-function-that-takes-an-array-of-objects-and-returns-an-array%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2f53943262%2fissue-in-calling-a-function-that-takes-an-array-of-objects-and-returns-an-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

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas