12 din 13
12
intrebari programare iPhone
  [ Ignoră ]   [ # 166 ]
Avatar
RankRankRankRank
Moderator
Din: Cluj-Napoca
Macuser din: 26.01.06

Cred ca este de la NULL, incearca nil. Am gasit ca:
NULL este pentru void*
nil este pentru id

 Semnătură 

Mcintoshing…

Profil
 
  [ Ignoră ]   [ # 167 ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06
ipdfdev - 13 Iunie 2011 06:37 PM

Am clasa de mai jos:

@interface PDFLinkAnnotation NSObject {
    CGPDFDictionaryRef annotationDictionary
;
}

- (id)initWithDictionary:(CGPDFDictionaryRef)newAnnotationDictionary;

@
end

@implementation PDFLinkAnnotation

- (id)initWithDictionary:(CGPDFDictionaryRef)newAnnotationDictionary {
    self 
[super init];
    if (
self{
        self
->annotationDictionary newAnnotationDictionary;
    
}
    
    
return self;
}

@end 

Si in codul aplicatiei am secventa urmatoare:

CGPDFDictionaryRef annotationDictionary NULL;            
if (
CGPDFArrayGetDictionary(annotsArrayj, &annotationDictionary;)) {
    PDFLinkAnnotation 
*linkAnnotation [[PDFLinkAnnotation alloc] initWithDictionaryannotationDictionary]// warning
    
[pageLinks addObjectlinkAnnotation];
    
[linkAnnotation release];

La compilare imi da un warning “Passing argument 1 of ‘initWithDictionary:’ from incompatible pointer type” la linia marcata cu //warning.
De doua zile ma uit la cod si nu imi dau seama de unde vine problema. Codul functioneaza fara probleme, dar as vrea sa scap de warning.
Poate observa cineva ce imi scapa mie.

Multumesc,
Sorin


Vezi ca -> folosesti doar daca variabilele sunt declarate @public,ca default ele sunt @protected si pot fi accesate ori direct ori self.numeVariabila daca ai metode de setter si getter sau proprietati.
Incearca sa folosesti fara self->

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil
 
  [ Ignoră ]   [ # 168 ]
Avatar
RankRankRank
Member
Din: Bucuresti
Macuser din: 11.10.05

Salut
Objective-C nu stie method overloading si ca atare initWithDictionary este deja luat de NSDictionary care se incarca din Foundation inaintea definitiilor asociate tale.

Daca compilezi cu clang e mai clar ce se intampla:

cristi:tmp diciu$ /Users/diciu/Programming/external/llvm//Debug/bin/clang -Wall test.m -framework Cocoa -framework ApplicationServices
test.m:35:87warningincompatible pointer types sending 'CGPDFDictionaryRef' (aka 'struct CGPDFDictionary *'to parameter of type 'NSDictionary *'
    
PDFLinkAnnotation *linkAnnotation [[PDFLinkAnnotation alloc] initWithDictionary:annotationDictionary]// warning
                                                                                      
^~~~~~~~~~~~~~~~~~~~
In file included from test.m:1:
In file included from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:21:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/NSDecimalNumber.h:8:
/
System/Library/Frameworks/Foundation.framework/Headers/NSDictionary.h:62:42notepassing argument to parameter 'otherDictionary' here
- (id)initWithDictionary:(NSDictionary *)otherDictionary;
                                         ^
test.m:35:24warningunused variable 'linkAnnotation' [-Wunused-variable]
    PDFLinkAnnotation 
*linkAnnotation [[PDFLinkAnnotation alloc] initWithDictionary:annotationDictionary]// warning
                       
^
2 warnings generated

Dupa cum vezi, initWithDictionary nu e un nume arbitrar si desi tu l-ai definit cu argument care nu este NSDictionary * compilatorul gaseste definitia in headerele de sistem si o foloseste.

Pentru a rezolva, poti folosi initWithPDFDictionary sau alt nume de metoda care nu este deja folosit.

Profil
 
  [ Ignoră ]   [ # 169 ]
Rank
Newbie
Din: Cluj-Napoca
Macuser din: 06.03.11

Multumesc pt ajutor, mi-ai rezolvat problema.

Profil
 
  [ Ignoră ]   [ # 170 ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06

Pai cum s-a rezolvat? Era de la NULL? De la -> sau de la numele metodei?

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil
 
  [ Ignoră ]   [ # 171 ]
Rank
Newbie
Din: Cluj-Napoca
Macuser din: 06.03.11

Era de la numele metodei. CGPDFDictionaryRef este un pointer C la o structura de tip CGPDFDictionary si se poate initializa cu NULL. Operatorul -> nu era implicat in problema, era mai mult pt mine, pt claritatea codului, sa stiu ca annotationDictionary este o variabila membru a clasei.

Profil
 
  [ Ignoră ]   [ # 172 ]
Avatar
RankRankRank
Member
Din: Bucuresti
Macuser din: 11.10.05

Sunt 99% convins ca nu e posibil in C ca inversarea NIL si null sa aiba ca efecte warning-uri la compilare.
Asta pentru ca dupa preprocesare devin acelasi lucru (void *)0 (vezi mai jos) si din ce stiu eu tot ce tine de compilare (inclusiv warning-urile) se intampla dupa pasul de preprocesare.

cristi:tmp diciucat test.m
#import <Cocoa/Cocoa.h>

int main()
{
    id t 
NULL;
    
id m nil;
    
id w = (void *)0;
cristi:tmp diciugcc -E test.tail
# 36 "/System/Library/Frameworks/CoreData.framework/Headers/CoreData.h" 2 3
# 14 "/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h" 2 3
# 2 "test.m" 2

int main()
{
 id t 
= ((void *)0);
 
id m = ((void *)0);
 
id w = (void *)0;


Si in C++ nil si NULL sunt acelasi lucru (doar ca devin ambele nullptr pentru ca C++ nu te mai lasa sa faci casting asa creativ ca in C):

cristi:tmp diciugcc -E test.mm tail
# 14 "/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h" 2 3
# 2 "test.mm" 2

int main()
{
 id t 
__null;
 
id m __null;
 
id w = (void *)0;
Profil
 
  [ Ignoră ]   [ # 173 ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06

Stie cineva ce inseamna @property strong?
Sau

@autoreleasePool {
...

Asta banuiesc ca inlocuiesc alloc/init…drain dar mi se pare ciudat smile

Iar noul empty project am observat ca nu are Main Nib.

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil
 
  [ Ignoră ]   [ # 174 ]
Avatar
RankRankRank
Member
Din: Bucuresti
Macuser din: 11.10.05

Sunt legate de noile feature-uri din Objective-C (automatic reference counting).
Automatic reference counting ar fi alternativa la retain/release-ul manual.

Vezi http://clang.llvm.org/docs/AutomaticReferenceCounting.html
si
http://clang.llvm.org/docs/AutomaticReferenceCounting.html#autoreleasepool

Profil
 
  [ Ignoră ]   [ # 175 ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06

Stiu ca au introdus ARC automatic reference counting,au disparut metodele dealloc iar daca apelezi release iti spune ca nu e disponibil in modul ARC.
Eu intrebam despre main nib si despre @property strong.

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil
 
  [ Ignoră ]   [ # 176 ]
RankRank
Jr. Member
Din: Bucuresti
Macuser din: 26.03.10

daca a parsat cineva vreun XML spreadsheet din excel folosind xPath as fi si eu curios de-un query ca nu-i dau de capat!!! :(

 Semnătură 

 iPhone 5 16GB black, iOS 7 beta 5
 MacBook Pro 15” Unibody, Late 2011 2,4 Ghz Intel Core i7, 8GB RAM, 128GB SSD, Radeon 6770 1GB, HiRes Display, OS X 10.8.3
 Thunderbolt Display

Profil
 
  [ Ignoră ]   [ # 177 ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06

A lucrat cineva cu in-app purchase?
Observerul meu primeste mereu transactionState = SKPaymentTransactionStateFailed si eroarea “cannot connect to itunes store”.
Aveti idee de ce?

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil
 
  [ Ignoră ]   [ # 178 ]
RankRank
Jr. Member
Din: Bucuresti
Macuser din: 26.03.10

http://troybrant.net/blog/2010/01/in-app-purchases-a-full-walkthrough/

 Semnătură 

 iPhone 5 16GB black, iOS 7 beta 5
 MacBook Pro 15” Unibody, Late 2011 2,4 Ghz Intel Core i7, 8GB RAM, 128GB SSD, Radeon 6770 1GB, HiRes Display, OS X 10.8.3
 Thunderbolt Display

Profil
 
  [ Ignoră ]   [ # 179 ]
RankRank
Jr. Member
Din: Bucuresti
Macuser din: 26.03.10

din cate-am inteles, pana sa ajungi la cod referitor la in-app purchases ai mare bataie de cap cu SKU si App ID bla, bla..

 Semnătură 

 iPhone 5 16GB black, iOS 7 beta 5
 MacBook Pro 15” Unibody, Late 2011 2,4 Ghz Intel Core i7, 8GB RAM, 128GB SSD, Radeon 6770 1GB, HiRes Display, OS X 10.8.3
 Thunderbolt Display

Profil
 
  [ Ignoră ]   [ # 180 ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06

Am creat un product ID nou,un user de test nou si a mers in final,oricum user-ul de test si testarea in sandbox merge doar daca user-ul e inregistrat pe US ...

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil
 
   
12 din 13
12
 
‹‹ Grand Central e acum Open Source      Fink ››