ios


How to code for a password needing a number and capital letter in objective c


Looking for coding or ideas to help me get a good start on ways for a program to check, after tapping a button, the a UITextField for at least one capital letter, at least one number and a length >= 6. Looking towards if statements so the else code could send out an alert telling its missing something.
am pretty much new to coding and was directed by my teacher to ask on here, thank you
I would recommend checking each one individually and then only logging on (progressing) if they all come back ok
Checking the length
// Check if the text is a certain length
if (textField.text.length >= 6) {
}
Checking that is contains a number
if ([textField.text rangeOfCharacterFromSet:[NSCharacterSet decimalDigitCharacterSet]].location != NSNotFound) {
}
Checking that it contains an uppercase character
NSString * string = textField.text;
int count = 0;
for (i = 0; i < [s length]; i++) {
BOOL isUppercase = [[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:[s characterAtIndex:i]];
if (isUppercase == YES)
count++;
}
This code is from here and loops through the string checking if there are upper case characters contained in it. You can then check the value of count to see if there is at least one it in. If you want a stronger password you can increase this check too.
In future though this is all quite basic stuff which just requires time to find out instead of knowledge of C. I didn't know how to do any of this before having a look to write this answer.
Hopefully this helps your understanding and, going forward, try spending 30 minutes searching with google before posting a duplicate question
Some more good questions on this can be seen below.
This answer here: is almost the same as the one you have asked
This answer also covers special characters: here
As Hot Licks says, this is not a "write my code for me" site. This is a site to get help with specific problems.
Take a look at the NSString class reference in Xcode. You should read the whole thing. It lists lots and lots of very useful methods. You won't understand it all at first, but note methods that sound like the would be useful.
Big hint: You'll also want to take a look at the NSCharacterSet class, and NSString methods that use NSCharacterSet to search in a string for characters that belong to specific set of characters.
Note that you could probably also use regular expressions. Cocoa includes the NSRegularExpression class, which lets you apply regular expressions to strings.

Related Links

How to change UI orientation without [UIDevice setValue:forKey:#“orientation”]
Using UNUserNotificationCenter to support iOS 10 rich notifications, but the notification never shows up. It only sounds the alert
When going back to the form from a PushRow table view scrolls up
didSelectRowAtIndex not firing
Download #2x and #3x images from server to Tableview
Swift: Multipeer Connectivity Manual Connect
Could it be possible that VOIP pushes get delayed or lost?
How can I declare new array to append tuple array?
Swift 3 weird crashes (type inference)
the image is not compressed in ios [closed]
initialization using ClassName.Type in Swift
Messages deleted in chat room re-appear after re-enter the chat room
How to play tick sound of UIPickerView on iOS 10?
CoreData migration failure
Swift / Populate UITableView with Array.count of elements matching certain condition
How to intercept “Messages” sent from CallKit incoming call screen?

Categories

HOME
ssl
gwt
azure-search
android-activity
appium-ios
windows-runtime
turing
xcode8
mocha
geany
pyusb
player-swift
range
plotly
python-xarray
identifier
bluej
google-cloud-sdk
prerender
helpers
flow
jscodeshift
profiling
naturallyspeaking
parallax
regex-group
editorconfig
feedly
codeceptjs
solarwindslem
dapper-fastcrud
stl
pyparsing
react-redux-form
detach
gosublime
phing
delete-row
draggable
presto
joe-editor
linechart
drupal-webform
atlassian-bitbucketserver
extjs4
h5py
azure-management-api
project-centennial
permgen
tabview
httpexception
program-slicing
kendo-chart
sql-insert
psycopg2
android-touch-event
plotrix
setwindowshookex
vb4android
ng-annotate
vlc-android
submission
restbed
cucumber-java
multiple-files
tag-helpers
multer
document-ready
openejb
spymemcached
equinox
maven-cargo
bloodhound
linegraph
gem5
windows-universal
sql-server-ce-3.5
vraptor
isql
excel-charts
office-2010
epoll
express-jwt
image-scaling
asp.net-apicontroller
xcode6.1.1
angularjs-google-maps
pdf-scraping
confirmation
nmea
ducttape
transport-stream
sugar.js
wow64
mosek
asp.net-authentication
route-me
arbtt
tempo
file-structure
code-structure
asp.net-session
teamcity-7.0
cellphone
f2c
jammit
springboard
facebook-authentication
.net-1.1
alivepdf
ryz
msn-messenger
posterous
gendarme
run-length-encoding
templatebinding
shareware

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App