How to get rid of warning “Result of call 'resignFirstResponder()' is unused”?
Since I converted my code to Swift 3
, I got a warning whenever I don't use the result of UITextField
's resignFirstResponder()
method.
There's no bugs ( at least for now ) but I don't really like to have warnings like that. So my questions:
- Should I actually use the results of this kind of call ? And if the answer yes, what should I do with them ?
- If the answer is no : how can I get rid of these warnings ?
ios swift warnings
add a comment |
Since I converted my code to Swift 3
, I got a warning whenever I don't use the result of UITextField
's resignFirstResponder()
method.
There's no bugs ( at least for now ) but I don't really like to have warnings like that. So my questions:
- Should I actually use the results of this kind of call ? And if the answer yes, what should I do with them ?
- If the answer is no : how can I get rid of these warnings ?
ios swift warnings
add a comment |
Since I converted my code to Swift 3
, I got a warning whenever I don't use the result of UITextField
's resignFirstResponder()
method.
There's no bugs ( at least for now ) but I don't really like to have warnings like that. So my questions:
- Should I actually use the results of this kind of call ? And if the answer yes, what should I do with them ?
- If the answer is no : how can I get rid of these warnings ?
ios swift warnings
Since I converted my code to Swift 3
, I got a warning whenever I don't use the result of UITextField
's resignFirstResponder()
method.
There's no bugs ( at least for now ) but I don't really like to have warnings like that. So my questions:
- Should I actually use the results of this kind of call ? And if the answer yes, what should I do with them ?
- If the answer is no : how can I get rid of these warnings ?
ios swift warnings
ios swift warnings
asked Oct 12 '16 at 11:58
RandyRandy
2,2621342
2,2621342
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
As Shaggy D
already said this warnings can be ignored safely.
If you don't want to see them at all in your project you may set GCC_WARN_UNUSED_VALUE
to false/NO
in Build Settings
.
Or just add let _ =
before resignFirstResponder()
:
let _ = resignFirstResponder()
add a comment |
1) You can ignore the result safely
2) Put these lines before the call :
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-result"
#pragma
? InSwift
?
– user28434
Oct 12 '16 at 12:33
@user28434 Sure in swift ! You need to create .pch file add it to build settings and add there whatever and it works
– Renetik
Nov 23 '18 at 4:16
add a comment |
resignFirstResponder will return false when the object you are asking to resign refuses to do so. For example, a text field will return false if it is in the middle of being edited, and I should imagine that the search bar in your example would do the same. If you ignore the result of these calls, therefore, you could get yourself into a bit of a mess.
Warnings in XCode can be annoying, but my personal view is that they are generally helpful and you should edit your code to get rid of them. When I'm working on a load of new code I tend to accrue warnings but always clean them down regularly.
In this situation I would advise you add some code to cover the eventuality of the search bar refusing to relinquish first responder status.
Hope that helps.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39998041%2fhow-to-get-rid-of-warning-result-of-call-resignfirstresponder-is-unused%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
As Shaggy D
already said this warnings can be ignored safely.
If you don't want to see them at all in your project you may set GCC_WARN_UNUSED_VALUE
to false/NO
in Build Settings
.
Or just add let _ =
before resignFirstResponder()
:
let _ = resignFirstResponder()
add a comment |
As Shaggy D
already said this warnings can be ignored safely.
If you don't want to see them at all in your project you may set GCC_WARN_UNUSED_VALUE
to false/NO
in Build Settings
.
Or just add let _ =
before resignFirstResponder()
:
let _ = resignFirstResponder()
add a comment |
As Shaggy D
already said this warnings can be ignored safely.
If you don't want to see them at all in your project you may set GCC_WARN_UNUSED_VALUE
to false/NO
in Build Settings
.
Or just add let _ =
before resignFirstResponder()
:
let _ = resignFirstResponder()
As Shaggy D
already said this warnings can be ignored safely.
If you don't want to see them at all in your project you may set GCC_WARN_UNUSED_VALUE
to false/NO
in Build Settings
.
Or just add let _ =
before resignFirstResponder()
:
let _ = resignFirstResponder()
answered Oct 12 '16 at 12:40
user28434user28434
3,4621226
3,4621226
add a comment |
add a comment |
1) You can ignore the result safely
2) Put these lines before the call :
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-result"
#pragma
? InSwift
?
– user28434
Oct 12 '16 at 12:33
@user28434 Sure in swift ! You need to create .pch file add it to build settings and add there whatever and it works
– Renetik
Nov 23 '18 at 4:16
add a comment |
1) You can ignore the result safely
2) Put these lines before the call :
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-result"
#pragma
? InSwift
?
– user28434
Oct 12 '16 at 12:33
@user28434 Sure in swift ! You need to create .pch file add it to build settings and add there whatever and it works
– Renetik
Nov 23 '18 at 4:16
add a comment |
1) You can ignore the result safely
2) Put these lines before the call :
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-result"
1) You can ignore the result safely
2) Put these lines before the call :
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-result"
answered Oct 12 '16 at 12:04
Shaggy DShaggy D
2,75811330
2,75811330
#pragma
? InSwift
?
– user28434
Oct 12 '16 at 12:33
@user28434 Sure in swift ! You need to create .pch file add it to build settings and add there whatever and it works
– Renetik
Nov 23 '18 at 4:16
add a comment |
#pragma
? InSwift
?
– user28434
Oct 12 '16 at 12:33
@user28434 Sure in swift ! You need to create .pch file add it to build settings and add there whatever and it works
– Renetik
Nov 23 '18 at 4:16
#pragma
? In Swift
?– user28434
Oct 12 '16 at 12:33
#pragma
? In Swift
?– user28434
Oct 12 '16 at 12:33
@user28434 Sure in swift ! You need to create .pch file add it to build settings and add there whatever and it works
– Renetik
Nov 23 '18 at 4:16
@user28434 Sure in swift ! You need to create .pch file add it to build settings and add there whatever and it works
– Renetik
Nov 23 '18 at 4:16
add a comment |
resignFirstResponder will return false when the object you are asking to resign refuses to do so. For example, a text field will return false if it is in the middle of being edited, and I should imagine that the search bar in your example would do the same. If you ignore the result of these calls, therefore, you could get yourself into a bit of a mess.
Warnings in XCode can be annoying, but my personal view is that they are generally helpful and you should edit your code to get rid of them. When I'm working on a load of new code I tend to accrue warnings but always clean them down regularly.
In this situation I would advise you add some code to cover the eventuality of the search bar refusing to relinquish first responder status.
Hope that helps.
add a comment |
resignFirstResponder will return false when the object you are asking to resign refuses to do so. For example, a text field will return false if it is in the middle of being edited, and I should imagine that the search bar in your example would do the same. If you ignore the result of these calls, therefore, you could get yourself into a bit of a mess.
Warnings in XCode can be annoying, but my personal view is that they are generally helpful and you should edit your code to get rid of them. When I'm working on a load of new code I tend to accrue warnings but always clean them down regularly.
In this situation I would advise you add some code to cover the eventuality of the search bar refusing to relinquish first responder status.
Hope that helps.
add a comment |
resignFirstResponder will return false when the object you are asking to resign refuses to do so. For example, a text field will return false if it is in the middle of being edited, and I should imagine that the search bar in your example would do the same. If you ignore the result of these calls, therefore, you could get yourself into a bit of a mess.
Warnings in XCode can be annoying, but my personal view is that they are generally helpful and you should edit your code to get rid of them. When I'm working on a load of new code I tend to accrue warnings but always clean them down regularly.
In this situation I would advise you add some code to cover the eventuality of the search bar refusing to relinquish first responder status.
Hope that helps.
resignFirstResponder will return false when the object you are asking to resign refuses to do so. For example, a text field will return false if it is in the middle of being edited, and I should imagine that the search bar in your example would do the same. If you ignore the result of these calls, therefore, you could get yourself into a bit of a mess.
Warnings in XCode can be annoying, but my personal view is that they are generally helpful and you should edit your code to get rid of them. When I'm working on a load of new code I tend to accrue warnings but always clean them down regularly.
In this situation I would advise you add some code to cover the eventuality of the search bar refusing to relinquish first responder status.
Hope that helps.
answered Oct 12 '16 at 12:36
MarcusMarcus
1,1461617
1,1461617
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39998041%2fhow-to-get-rid-of-warning-result-of-call-resignfirstresponder-is-unused%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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