[Résolu] rangeOfString dans une condition

juillet 2014 modifié dans API UIKit #1

Bonjour à  tous,


 


Ma question est dans le titre, j'ai ce code :



[urlCapture2string rangeOfString:@?]

J'aimerais l'inclure dans un if. A moins qu'une autre méthode soit plus appropriée ? L'idée c'est de contrôler si il y a un point d'interrogation dans l'URL, si oui, alors je traite.


 


Merci pour votre aide.


Réponses

  • LarmeLarme Membre
    juillet 2014 modifié #2

    if ([urlCapture2string rangeOfString:@?].location != NSNotFound)

    Car :

     



    rangeOfString:


    Finds and returns the range of the first occurrence of a given string within the receiver.

    - (NSRange)rangeOfString:(NSString *)aString

    Parameters

    aString

    The string to search for. This value must not be nil.

    Raises an NSInvalidArgumentException if aString is nil.

    Return Value

    An NSRange structure giving the location and length in the receiver of the first occurrence of aString. Returns {NSNotFound, 0} if aString is not found or is empty (@"").


     



  • hmmm, ok, c'est le location qu'il me manquait. Merci :)


Connectez-vous ou Inscrivez-vous pour répondre.