objectivec.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. @protocol Printing: someParent
  2. -(void) print;
  3. @end
  4. @interface Fraction: NSObject <Printing, NSCopying> {
  5. int numerator;
  6. int denominator;
  7. }
  8. @end
  9. @"blah\8" @"a\222sd\d" @"\faw\"\? \' \4 n\\" @"\56"
  10. @"\xSF42"
  11. -(NSDecimalNumber*)addCount:(id)addObject{
  12. return [count decimalNumberByAdding:addObject.count];
  13. }
  14. NS_DURING NS_HANDLER NS_ENDHANDLER
  15. @try {
  16. if (argc > 1) {
  17. @throw [NSException exceptionWithName:@"Throwing a test exception" reason:@"Testing the @throw directive." userInfo:nil];
  18. }
  19. }
  20. @catch (id theException) {
  21. NSLog(@"%@", theException);
  22. result = 1 ;
  23. }
  24. @finally {
  25. NSLog(@"This always happens.");
  26. result += 2 ;
  27. }
  28. @synchronized(lock) {
  29. NSLog(@"Hello World");
  30. }
  31. struct { @defs( NSObject) }
  32. char *enc1 = @encode(int);
  33. IBOutlet|IBAction|BOOL|SEL|id|unichar|IMP|Class
  34. @class @protocol
  35. @public
  36. // instance variables
  37. @package
  38. // instance variables
  39. @protected
  40. // instance variables
  41. @private
  42. // instance variables
  43. YES NO Nil nil
  44. NSApp()
  45. NSRectToCGRect (Protocol ProtocolFromString:"NSTableViewDelegate"))
  46. [SPPoint pointFromCGPoint:self.position]
  47. NSRoundDownToMultipleOfPageSize
  48. #import <stdio.h>
  49. int main( int argc, const char *argv[] ) {
  50. printf( "hello world\n" );
  51. return 0;
  52. }
  53. NSChangeSpelling
  54. @"0 != SUBQUERY(image, $x, 0 != SUBQUERY($x.bookmarkItems, $y, $y.@count == 0).@count).@count"
  55. @selector(lowercaseString) @selector(uppercaseString:)
  56. NSFetchRequest *localRequest = [[NSFetchRequest alloc] init];
  57. localRequest.entity = [NSEntityDescription entityForName:@"VNSource" inManagedObjectContext:context];
  58. localRequest.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"resolution" ascending:YES]];
  59. NSPredicate *predicate = [NSPredicate predicateWithFormat:@"0 != SUBQUERY(image, $x, 0 != SUBQUERY($x.bookmarkItems, $y, $y.@count == 0).@count).@count"];
  60. [NSPredicate predicateWithFormat:]
  61. NSString *predicateString = [NSString stringWithFormat:@"SELF beginsWith[cd] %@", searchString];
  62. NSPredicate *pred = [NSPredicate predicateWithFormat:predicateString];
  63. NSArray *filteredKeys = [[myMutableDictionary allKeys] filteredArrayUsingPredicate:pred];
  64. localRequest.predicate = [NSPredicate predicateWithFormat:@"whichChart = %@" argumentArray: listChartToDownload];
  65. localRequest.fetchBatchSize = 100;
  66. arrayRequest = [context executeFetchRequest:localRequest error:&error1];
  67. [localRequest release];
  68. #ifndef Nil
  69. #define Nil __DARWIN_NULL /* id of Nil class */
  70. #endif
  71. @implementation MyObject
  72. - (unsigned int)areaOfWidth:(unsigned int)width
  73. height:(unsigned int)height
  74. {
  75. return width*height;
  76. }
  77. @end